Vue完整版与不完整版

337 阅读1分钟

1. vue完整版与不完整版的使用

完整版

可以在vue的使用文档中查看安装步骤cn.vuejs.org/
使用CDN引用完整版(注意后缀是vue.js)cdn.bootcdn.net/ajax/libs/v…

Image.png 视图写在templaten内或者写html文件内时,此时必须使用完整版。 new Vue({ template: '<div>{{ hi }}</div>' })

不完整版

使用CDN引用不完整版(注意后缀是runtime.min.js) cdn.bootcdn.net/ajax/libs/v…

Image.png 不需要编译器即使用不完整版时 new Vue({ render (h) { return h('div', this.hi) } })

区别

  • 完整版内有compiler可以将html编译
  • 不完整版本身不具备compiler但是可以通过webpack内的vue-loader对html进行编译
  • 不完整版比完整版的体积少40%

在codesanbox.io写vue代码

image.png

image.png