- 報錯內(nèi)容: [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available
- 報錯原因:在vue運行時內(nèi)部渲染組件就會報錯。(代碼在最下面)
- 解決方法:如果是vue-cli創(chuàng)建的項目,會有vue.config.js,在里面新增一條:runtimeCompiler: true 即可,這個配置項允許在vue實例內(nèi)部再次掛載新的vue實例。
- 為什么你會報這個錯?在將之前做的服務端渲染的項目代碼遷移到純前端vue的時候遇到的。
// 導致報錯的代碼
new Vue({
...
}).mount(...);
// 解決方法
// vue.config.js
module.exports = {
...,
runtimeCompiler: true,
};