VUE的两种版本

411 阅读1分钟

运行时版本vue.runtime.js

  • 没有complier,体积减小;
  • 视图是写在render函数里,用h来创建标签;
  • 不支持template,需通过webpack的工具vue-loader将组件预编译template模板编译为render函数。

完整版vue.js

  • 有complier编译器,complier占40%的体积;
  • 写在HTML标签里,或者写进template选项;

template 和 render

不完整版(不需要编译器):

new Vue({
  render(h){ return h('div', [this.n,h('{on:{click:this.add}’,'+1'])}
})

完整版(需要编译器):

new Vue({
  el:,
  template:`<div>{{n}}</div>` //从js里产生HTML里产生视图内容
})

如何用 codesandbox.io 写 Vue 代码

codesandbox代码沙盒

  1. 如果登录只能创建50个项目,不登录可以创建无数个:)
  2. 进入网站后点击 Create a Sandbox it's free 创建项目;
  3. 选择你要创建的项目模板类型即可进入编程(如图);
  4. 做完一个项目的时候可以通过file目录找到Export to ZIP导出你的文件,以压缩包的形式。