代码学堂(uxuew.cn)提供付费解决PHP WEB开发等技术服务,如果需要请 点击加我QQ:1662935793.
>web前端 > vuejs学习 > Error compiling template:Component template should contain exactly one root elem

Error compiling template:Component template should contain exactly one root elem

vuejs学习 围观5875次 更新日期:2017-07-26 14:47:35 留下足迹

vue报错信息如下:
/~/vue-loader/lib/template-compiler?{"id":"data-v-291f653e"}!./~/vue-loader/lib/selector.js?type=template&index=0!./src/views/index.vue
(Emitted value instead of an instance of Error) 
  Error compiling template:
  
  
  <el-radio-button :label="false">展开</el-radio-button>
  <el-radio-button :label="true">收起</el-radio-button>
  
  
  - Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
大概意思就是说: 组件模版应该被包含在一个确切的根目录


原报错模版:
<template>
  <el-radio-button :label="false">展开</el-radio-button>
  <el-radio-button :label="true">收起</el-radio-button>
</template>
解决方法:在模版元素包含在一个标签内即可,如 div 等
<template>
  <div>
  <el-radio-button :label="false">展开</el-radio-button>
  <el-radio-button :label="true">收起</el-radio-button>
  </div>
</template>

转载请注明:代码学堂>web前端 > vuejs学习 > Error compiling template:Component template should contain exactly one root elem

喜欢 (303) or 分享 (335)