组件嵌套时报: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 ...
 
随机推荐
- VS2008中C#开发webservice简单实例
			
1.创建工程 文件-> 新建->网站 如下图. 工程建好后,会自动添加如下代码: using System; using System.Linq; using System.Web; us ...
 - 50 years, 50 colors
			
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
 - PHP基础入门(二)【PHP函数基础】
			
PHP基础入门(二)--函数基础 了解 PHP基础入门详解(一) 后,给大家分享一下PHP的函数基础. 这部分主要讲的就是: 函数的声明与使用.PHP中变量的作用域.静态变量.函数的参数传递.变量函数 ...
 - Mysql修改已有数据的字符集
			
Mysql修改已有数据的字符集 问题 在生产环境中跑了很久,发现MysqlClient连接的字符集是默认的latin1,我们一直以为都是utf8,造成这样的误解,是因为在内网环境中,我们是源码编译的M ...
 - 关于缓存问题:js清除缓存
			
css并行加载,js串行加载(会阻塞页面) 清除缓存的问题: 1.一般手动清除,浏览器缓存 2.js代码清除缓存(原理:增加了一个参数,且该参数是一个随机数,每次都不一样,所以每次的请求参数都不一样, ...
 - aria-label
			
元素中的 aria-label用来命名一个元素 它的值可以是任何字符 读屏软件就会读出aria-label里的内容 <div role=”form” aria-labelledby= ...
 - jQuery选择器(添加节点及删除节点及克隆及替换及包装)第九节
			
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
 - 《天书夜读:从汇编语言到windows内核编程》四 windows内核调试环境搭建
			
1) 基础篇是讲理论的,先跳过去,看不到代码运行的效果要去记代码是一个痛苦的事情.这里先跳入探索篇.其实今天的确也很痛苦,这作者对驱动开发的编译与调试环境介绍得太模糊了,我是各种尝试,对这个环境的搭建 ...
 - python基础(三)----字符编码以及文件处理
			
字符编码与文件处理 一.字符编码 由字符翻译成二进制数字的过程 字符--------(翻译过程)------->数字 这个过程实际就是一个字符如何对应一个特定数字的标准,这个标准称之 ...
 - Docker 三剑客之 Compose
			
Compose 项目是 Docker 官方的开源项目,负责实现对 Docker 容器集群的快速编排,开源地址:https://github.com/docker/compose Compose 中的两 ...