在用vue+iview開發(fā)時發(fā)現(xiàn)一個錯誤咖楣,具體報錯如下
error in ./src/components/page/Test.vue
(Emitted value instead of an instance of Error)
Vue template syntax error:
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.
@ ./src/components/page/Test.vue 5:2-167
@ ./src/router/index.js
@ ./src/main.js
@ multi ./build/dev-client babel-polyfill ./src/main.js
在一個vue組件中我只是添加了一個按鈕或一個div標簽督笆,就會報出這個錯誤。
<template>
<Button type="primary" size="large"><Icon type="ios-download-outline"></Icon> 導出原始數(shù)據(jù)</Button>
<Table border :columns="columns3" :data="data1"></Table>
</template>
原來vue模板只能有一個根對象所以你想要出現(xiàn)正常的效果诱贿,你的用一個div來或是別的標簽來包裹全部的元素正確的寫法就是:
<template>
<div>
<Button type="primary" size="large"><Icon type="ios-download-outline"></Icon> 導出原始數(shù)據(jù)</Button>
<Table border :columns="columns3" :data="data1"></Table>
</div>
</template>