vue 安装指定版本swiper_Vue中的runtime-only和runtime-compiler
在我們使用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
總結
以上是生活随笔為你收集整理的vue 安装指定版本swiper_Vue中的runtime-only和runtime-compiler的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 英雄联盟中受到防沉迷系统限制,如何解除?
- 下一篇: 哈利波特手游怎么进入海格小屋