vue
vue 安装指定版本swiper-凯发ag旗舰厅登录网址下载
在我们使用vue-cli的时候,会提示你安装的版本
可以看到有两种版本:routime only和runtime compiler版本
1.runtime only - 代码中不可以有任何template 性能更高
在该版本下,通常需要借助如webpack的vue-loader发工具把.vue文件编译成js
因为是在编译阶段做的,所以它只包含运行时的vue.js代码,因此代码体积也会更轻量。
在将.vue文件编译成js的编译过程中会将组件中的template模板编译为render函数,所以我们得到的是render函数的版本。所以运行的时候是不带编译的,编译是在离线的时候做的。
2.runtime compiler -代码中可以有template 因为有compiler可以编译 性能较低
我们如果没有对代码做预编译,但又使用了vue的template属性并出入一个字符串,则需要在客户端编译模板,如下所示:
// 需要编译器的版本 new vue({template: '{{ hi }}' })// 这种情况不需要 new vue({render (h) {return h('div', this.hi)} })因为在vue.js 2.0中,最终渲染都是通过render函数,如果写template属性,则需要编译成render函数,那么这个编译过程都会发生运行时,所以需要带有编译器的版本。
以下情况会使用到compiler:
1) 有指定的template;
2) 没指定template,也没指定render(这时候使用的就是被挂载元素的outerhtml)
因此,没有使用到compiler的情况只有:没有指定的template,但指定了render。
有时候会遇到这样的错误:
[vue warn]: you are using the runtime-only build of vue where the template compiler is not available. either pre-compile the templates into render functions, or use the compiler-included build.怎么解决:
webpack.conff.js中进行配置以下配置:
2020.02.04 11:30
总结
以上是凯发ag旗舰厅登录网址下载为你收集整理的vue 安装指定版本swiper_vue中的runtime-only和runtime-compiler的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。
- 上一篇:
- 下一篇: