组件嵌套时报: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.
在组件嵌套的过程中,报了一个错误:
这里报错的原因是:vue的组件(模板)只能有一个根节点,即.vue文件中的<template>标签下只能有一个子元素。
因此,建议大家在写.vue组件的时候,最好在<template>下添加一个标签(比如div),在这个标签里面写我们的组件。
例如:
<template>
<div>
<!--你的组件代码-->
</div>
</template>
我这边就是用这种方法解决的。也希望能帮助到大家。
组件嵌套时报: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.的更多相关文章
- VUE之命令行报错: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 解决办法
Failed to compile. ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-5992 ...
- vue报错: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.
在.vue文件中引入了 element-ui 的 table 和 pagination 组件后,报错:Component template should contain exactly one roo ...
- VUE编译报错 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
背景: 在使用VUE添加标签的时候编译报错,报错如下: Component template should contain exactly one root element. If you are u ...
- vue父子组件嵌套的时候遇到 - Component template should contain exactly one root element. If you are using v-i
转自:https://blog.csdn.net/yangyiboshigou/article/details/72084619
- 【错误总结】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.
大致意思是因为模板里面应该包含一个根元素,使用组件的时候应该用div或p标签包起来
- 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.
运行代码时,一直报错: 经过查询后才知道,vue模板只能有一个跟对象 我是这样写的 最后修改为 就可以正常运行了
- vue-父子组件嵌套的示例
组件注册: // 注册组件 Vue.component('my-component', { template: '<div>A custom component!</div>' ...
- Vue出现Component template should ...
当运行vue出现错误Component template should contain exactly one root element. If you ...的时候,我们只需要将<templa ...
- Vue.js组件嵌套和template外用
Vue.extend组件的嵌套和template外用 组件嵌套分为全局组件嵌套和局部组件嵌套 组件嵌套需要将子元素写在父元素内 子组件必须在父组件中注册之后才能在父组件的模板中使用 全局组件嵌套 Vu ...
随机推荐
- [Bayesian] “我是bayesian我怕谁”系列 - Latent Variables
下一章有意讲讲EM和变分推断的内容. EM和变分推断的内容能Google到很多,虽然质量乘次不齐,但本文也无意再赘述那么些个细节. 此处记录一些核心思想,帮助菜鸡形成整体上的认识.不过,变分推断也不是 ...
- fiddler学习资源
小坦克 fiddler教程:http://www.cnblogs.com/TankXiao/archive/2012/04/25/2349049.htmlps:另外博主其他测试文章也值得一看 涂根 ...
- Django开发小型站之前期准备(一)
语言:python3.5 工具:JetBrains PyCharm virtualenvwrapper优点: 1.使不同的应用开发环境独立 2.环境升级不影响其他应用,也不会影响全局的python环境 ...
- poj 1155 TELE(树形DP)
TELE Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4863 Accepted: 2673 Description ...
- App网络管理
安卓开发一般都需要进行日志管理,常用操作老司机已为你封装完毕,你可以用这份工具进行管理,具体可以查看源码,现在为你开车,Demo传送门. 站点 系统日志输出工具类 → AppKeyBoardMgr g ...
- js 函数声明和函数表达式
在ECMAScript中,创建函数的最常用的两个方法是函数表达式和函数声明,因为ECMA规范只明确了一点:函数声明必须带有标示符(Identifier)(就是大家常说的函数名称),而函数表达式则可以省 ...
- html的块级元素和内联元素
常用的块级元素: address , center , div , dl ,, form , h1 , h2 , h3 , h4 , h5 , h6 , menu , ol , p , table , ...
- 使用spring框架中的组件发送邮件
首先进入自己的QQ邮箱,在设置中修改账户信息 然后来至底部 点击开启,再用手机发送对应信息到指定号码,然后点击我已发送 获取授权码 注意提示: 到这里,相信你已经开通了SMTP服务,这样就可以在 ...
- 【Python】Non-ASCII character '\xe6' 错误解决方法
刚刚在写Python程序的时候遇到了一个问题,无论是在程序中什么地方出现中文字符,都会出现如下错误 SyntaxError: Non-ASCII character '\xe6' 网上查阅了一下这应该 ...
- windows服务启动有界面的程序
大家写windows服务守护进程的时候,肯定会遇到启动的程序看不到界面,只能在任务管理器里面看到xxx.exe问题. 发现可能有如下情况 a.无论是开机,还是程序被关掉后,守护服务启动的程序只能看到任 ...