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 解决办法的更多相关文章

  1. 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 ...

  2. VUE之命令行报错:Expected indentation of 4 spaces but found 6

    使用vue时候,经常被一大片警告惊呆了,这是webpack默认的语法检查插件ESLint在做警告, [ESLint是一个语法规则和代码风格的检查工具,可以用来保证写出语法正确.风格统一的代码] 但是我 ...

  3. 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 ...

  4. UE初写小项目问题之命令行报错:Expected indentation of 4 spaces but found 6

    一.问题 刚开始用一个小项目练手,用vue-cli初始化项目,直接安装了所有的东西,如vue-router.ESLint.unit tests等等,当时只懂得vue-router是什么. 问题来了,在 ...

  5. npm执行命令行报错

    今天在学习react-router时候使用命令npm start 报了一个错误 npm ERR! missing script: start npm ERR! A complete log of th ...

  6. webpack 命令行报错“webpack” 不是内部或外部命令的解决方法

    1. NodeJS安装,笔者安装在D盘.安装目录中有两个文件夹node_cache,node_global如下: 2. 配置 npm安装路径,输入如下命令: npm config set prefix ...

  7. Mac 终端命令行报错 -bash: vi: command not found

    我遇到的问题与这个类似,但是我的问题也是用该博文作者方法进行中断才解决的,在此表示感谢. 前段时间在 Mac 下使用终端遇到了这个问题: appledeMacBook-Air:~ air$ vi .b ...

  8. 组件嵌套时报: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组件的 ...

  9. 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模板只能有一个跟对象 我是这样写的 最后修改为 就可以正常运行了

随机推荐

  1. 浅探webpack优化

    由于前端的快速发展,相关工具的发展速度也是相当迅猛,各大框架例如vue,react都有自己优秀的脚手架工具来帮助我们快速启动一个新项目,也正式因为这个原因,我们对于脚手架中最关键的一环webpack相 ...

  2. springboot maven 多环境配置

    1.使用Intellij IDEA创建Spring Boot和Maven项目 2.Spring Boot项目下application.yaml(yaml支持中文)或者application.prope ...

  3. ccf 201712-4 行车路线(Python实现)

    一.原题 问题描述 试题编号: 201712-4 试题名称: 行车路线 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 小明和小芳出去乡村玩,小明负责开车,小芳来导航. 小芳将 ...

  4. 嵌入式入门学习笔记3:[转]编译linux

    摘自:https://blog.csdn.net/baidu_24256693/article/details/80115354 编译Linux是什么意思? Linux内核是Linux操作系统的核心, ...

  5. 合肥工业大学宣城校区大学生创新创业训练项目申报书:“基于Spark平台的人工智能知识的知识图谱构建”

  6. MVC&JQuery如何根据List动态生成表格

    背景:在编码中,常会遇到根据Ajax的结果动态生成Table的情况,本篇进行简要的说明.这已经是我第4.5篇和Ajax有关的随笔了,互相之间有很多交叠的地方,可自行参考. 后台代码如下: public ...

  7. #1 add life to static pages && connect to MySQL

    由于实验室 Project 中需要用到PHP, 之前也没接触过 PHP, 因此把 编程入门 <Head Fist PHP & MySQL >找来花了四五天快速过了一遍. 现在想把书 ...

  8. java web开发基础实例(javabean+jsp+servlet+jdbc)

    JavaBean:用于传递数据,拥有与数据相关的逻辑处理 JSP:从Model接收数据并生成HTML Servlet:接收HTTP请求并控制Model和View jdbc:用于配置环境 一.[建立数据 ...

  9. js---post与get请求的区别

    request获取请求参数 最为常见的客户端传递参数方式有两种: 浏览器地址栏直接输入:一定是GET请求: 超链接:一定是GET请求: 表单:可以是GET,也可以是POST,这取决与<form& ...

  10. [git 学习篇] 关联github和本地创库

    所以,github和本地创库是通过ssh传送,所以要将公钥拷贝到远程创库上(比如我ssh 远程服务器时,先将本地的公钥,拷贝到远程服务器的某个文件上(http://www.cnblogs.com/li ...