Vue 两个版本的区别和使用方法
- 两个版本对应的文件名
vue.js(完整版):有compiler;视图写在html里或者写在template选项;cdn引入vue.js;webpack引入需要配置alias;@vue/li引入需要额外配置;vue.runtime.js(运行时版):没有conpiler;视图写在render函数里,用h来创建标签;cdn引入vue.runtime.js;webpack与@vue/li引入默认使用非完整版
template和render怎么用
<template>
<div id="app">
{{n}}
<button @click="add">+1</button>
</div>
</template>
vue非完整版只能写到render里面
render(h){
return h('div',[this.n,h('button',{on:{click:this.add}},'+1')])
}
- 教读者如何用 codesandbox.io 写 Vue 代码
进入https://codesandbox.io/s/网站选择vue即可