VUE 初探

198 阅读1分钟

Vue 两个版本的区别和使用方法

  1. 两个版本对应的文件名
  • vue.js(完整版):有compiler;视图写在html里或者写在template选项;cdn引入vue.jswebpack引入需要配置alias@vue/li引入需要额外配置;
  • vue.runtime.js(运行时版):没有conpiler;视图写在render函数里,用h来创建标签;cdn引入vue.runtime.jswebpack@vue/li 引入默认使用非完整版
  1. templaterender 怎么用
<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')])
}
  1. 教读者如何用 codesandbox.io 写 Vue 代码

进入https://codesandbox.io/s/网站选择vue即可