vue的使用
第一步:导包
官方提供两个包:生产包、开发包
开发包:vue.js
生产包:vue.min.js
<script src="/js/vue.js"></script>
第二步:构建html
<div class="box">{{ content }}</div>
第三步:使用vue
window.onload = function(){
var vm = new Vue({
el: '.box',
data: {
content: 'xxxx'
}
});
}
示例:
<head>
// 01 导包
<script src="/js/vue.js"></script>
<script>
// 03 监听
window.onload = function(){
// 04 创建vue
var vm = new Vue({
// 05 绑定操作对象
el: '.box',
data: {
content: 'xxxx'
}
});
}
</script>
</head>
<body>
// 02 构建HTML
<div class="box">{{ content }}</div>
</body>