鍍金池/ 問答/HTML/ Vue2.0報錯Failed to mount component: templ

Vue2.0報錯Failed to mount component: template....

vue-cli構(gòu)建項目,vue版本2.0+
組件player應(yīng)用在App.vue里面,一直報錯

clipboard.png

谷歌+百度之后,大概是知道Vue2.0+以后默認不采用template渲染DOM了,需要在webpack.config.js里面修改

 'vue'  : 'vue/dist/vue.min',

疑問如下:
1)既然2.0以上版本不再采用tempalte渲染dom,為什么我們每次在寫.vue文件的時候,還是按照

<template></template>
<script></script>
<style></style>  

這樣寫
2)我那樣修改之后('vue' : 'vue/dist/vue.min',)是不報錯的,但是DOM并沒有渲染
求問解決方式-----QAQ-------

回答
編輯回答
傻叼

The reason you're receiving that error is that you're using the runtime build which doesn't support templates in HTML files as seen here vuejs.org

In essence what happens with vue loaded files is that their templates are compile time converted into render functions where as your base function was trying to compile from your html element.

2018年1月3日 23:33
編輯回答
陌南塵

你只用了運行時的vue腳本,需要vue-loader來處理vue文件

2017年7月21日 12:18