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-59926570","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/page/home/Home.vue
(Emitted value instead of an instance of Error)
Error compiling template:
<div><el-header class="animated faedOutUp"><myHeader></myHeader></el-header></div>
<div>这里才是首页</div>
- 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/page/home/Home.vue 11:0-366
@ ./src/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
写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这句话已经讲的很明白了,直译出来 就是:组件模板应该包含一个根元素。如果在多个元素上使用V-IF,则使用V-ELS-IF来链接它们。
但是这么说依然让新手有点摸不着头脑,其实就是说在模版里只能有一个主div(根对象),如果有多个元素,请用一个主div包含他们
错误代码如下:
<template>
<div><el-header class="animated faedOutUp"><myHeader></myHeader></el-header></div>
<div>这里才是首页</div>
</template>
修改后如下
<template>
<div>
<el-header class="animated faedOutUp"><myHeader></myHeader></el-header>
<div>这里才是首页</div>
</div>
</template>
保存运行,错误解决了!

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 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之命令行报错:Expected indentation of 4 spaces but found 6
使用vue时候,经常被一大片警告惊呆了,这是webpack默认的语法检查插件ESLint在做警告, [ESLint是一个语法规则和代码风格的检查工具,可以用来保证写出语法正确.风格统一的代码] 但是我 ...
- 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 ...
- UE初写小项目问题之命令行报错:Expected indentation of 4 spaces but found 6
一.问题 刚开始用一个小项目练手,用vue-cli初始化项目,直接安装了所有的东西,如vue-router.ESLint.unit tests等等,当时只懂得vue-router是什么. 问题来了,在 ...
- npm执行命令行报错
今天在学习react-router时候使用命令npm start 报了一个错误 npm ERR! missing script: start npm ERR! A complete log of th ...
- webpack 命令行报错“webpack” 不是内部或外部命令的解决方法
1. NodeJS安装,笔者安装在D盘.安装目录中有两个文件夹node_cache,node_global如下: 2. 配置 npm安装路径,输入如下命令: npm config set prefix ...
- Mac 终端命令行报错 -bash: vi: command not found
我遇到的问题与这个类似,但是我的问题也是用该博文作者方法进行中断才解决的,在此表示感谢. 前段时间在 Mac 下使用终端遇到了这个问题: appledeMacBook-Air:~ air$ vi .b ...
- 组件嵌套时报: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组件的 ...
- 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模板只能有一个跟对象 我是这样写的 最后修改为 就可以正常运行了
随机推荐
- 配置基于Vim的Python开发环境
配置基于Vim的Python开发环境插件 Vundle YouCompleteMe NERDTree Vim-Jinja2-Syntax set nocompatible " be iMpr ...
- 20.Yii2.0框架多表关联一对多查询之hasMany
目录 新手模式 hasMany关联模式查询 新建mode层Article.php 新建mode层Category.php 新建控制器HomeController.php 新手模式 用上次的查询结果,作 ...
- python3.7 文件操作
#!/usr/bin/env python __author__ = "lrtao2010" #python3.7 文件操作 # r 只读,默认打开方式,当文件不存在时会报错 # ...
- Applied Nonparametric Statistics-lec4
Ref: https://onlinecourses.science.psu.edu/stat464/print/book/export/html/5 Two sample test 直接使用R的t- ...
- python模块之shutil和zipfile
shutil 模块 高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length])将文件内容拷贝到另一个文件中 import shutil s ...
- python基础之文件处理总结
读文件: with open('contacts.txt', 'r', encoding='utf-8') as f: data = f.read() 二进制模式读 使用场景:网络传输(视频.图片或进 ...
- POJ:2695-The Pilots Brothers' refrigerator
题目链接:http://poj.org/problem?id=2965 The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limi ...
- 面试(手打手写,待更新loading...)
1)JAVA基础面试 1,引用数据类型和基本数据类型的区别是什么? Byte 1 short 2 int 4 long 8 Boolean 1 char 2 float 4 double 8. 基本数 ...
- python基础学习笔记——类的成员
一. 细分类的组成成员 之前咱们讲过类大致分两块区域,如下图所示: 每个区域详细划分又可以分为: class A: company_name = '老男孩教育' # 静态变量(静态字段) __ipho ...
- loj2026 「JLOI / SHOI2016」成绩比较
orz #include <iostream> #include <cstdio> using namespace std; typedef long long ll; int ...