天天看點

vue中Component錯誤

報錯:Component you should use exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

翻譯:元件應該隻使用一個根元素。 如果您在多個元素上使用v-if,請使用v-else-if來連結它們。

原因:元件中<template></template>标簽内缺少根元素

解決:添加根元素<div></div>

<template>
    <div>
        内容
    </div>
</template>