Vue CLI:The template root requires exactly one element
最近更新時間 2020-03-11 21:55:57
在 Vue CLI 開發中,新建模板文件如下所示:
<template>
</template>
<script>
export default {
name: 'T'
}
</script>
<style scoped>
</style>
後會出現如下錯誤信息:
ERROR Failed to compile with 1 errors 12:53:34 PM
error in ./src/views/test/Query.vue
Module Error (from ./node_modules/eslint-loader/index.js):
/src/views/test/Query.vue
1:1 error The template root requires exactly one element vue/valid-template-root
✖ 1 problem (1 error, 0 warnings)
@ ./src/routes/inner.js 25:9-35
@ ./src/routes/index.js
@ ./src/plugins/router.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://127.0.0.1:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
解決辦法,需在 <template> 下添加一個任意元素。