怎么使用VUE
步骤
- 使用步骤
- 1:引包,具备vue对象
- 2:启动vue 通过 new Vue(options);
- 3:配置options对象
- 4:参数:el: '目的地' template: '模板' data: function () {return { '要使用的key : 数据' }}
- 5:页面中存在该目的地,同jq语法
代码
<div id="app"></div>
<!-- 引包 vue.js有报错信息 vue.min.js压缩后的没有报错信息-->
<script src="./node_modules/vue/dist/vue.js"></script>
<script>
new Vue({
// el: 发生行为的目的地
// el: document.getElementById('app');
el: '#app',
// template: 装载的模板
template: '<div><h1>大家好 {{text}}</h1></div>',
// 动态数据的声明
data: function() {
return {
// template 中需要的数据
text: 'hello vue',
}
}
})