粗识Vue,本文将简单介绍下Vue完整版和非完整版。
一、两个版本的区别和使用方法
- 完整版(
vue.js), - 非完整版也叫运行时版本(
vue.runtime.js)。
| Vue完整版 | Vue非完整版 | 评价 | |
|---|---|---|---|
| 特点 | 有 compiler | 没有 compiler | compiler 占 40% 体积 |
| 视图 | 写在 HTML 里 或者写在 template 选项 | 写在 render 函数里用 h 来创建标签 | h 是尤雨溪写好传给 render 的 |
| cdn引入 | vue.js | vue.runtime.js | 文件名不同,生产环境后缀为 .min.js |
| webpack引入 | 需要配置 alias | 默认使用此版 | 尤雨溪配置的 |
| @vue/cli引入 | 需要额外配置 | 默认使用此版 | 尤雨溪、蒋豪群配置的 |
二、template和render
- 完整版
// 需要编译器
new Vue({
template: '<div>{{ hi }}</div>'
});
- 非完整版
// 不需要编译器
new Vue({
render (h) {
return h('div', this.hi)
}
});
怎样快速创建Vue的demo
可以尝试codesandbox在线创建Vue小项目
- 在首页点击Vue的icon即可创建