组件:数据

<!DOCTYPE html>
<html lang="zh">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <link href="../css/style.css" rel="stylesheet"> </head>
<body>
<div id="myApp">
    <div>今天的天气是<today-weather/></div>
</div>
<script>
    Vue.component('today-weather', {
        template: '<strong>{{todayWeather}}</strong>',
        data: function(){
            return {
                todayWeather: '雨加雪'
            };
        }
    });
    var myApp = new Vue({
        el: '#myApp', 
    });
</script>
</body>

</html>

 

上一篇:处理用户输入


下一篇:js放到head中失效的原因与解决方法