问答详情
源自:2-10 router实现子路由(2)

那位大哥解释下,我A1.vue,p标签要是超过1个他就报错,但是如果A1.vue只有一个p标签他就不会报错

http://img4.mukewang.com/5e6920ae000114f208210501.jpg

http://img.mukewang.com/5e6920ae0001c48508490462.jpg

http://img.mukewang.com/5e6920ae0001a24508540545.jpg

http://img2.mukewang.com/5e6920af0001ff9010110866.jpg

http://img.mukewang.com/5e6920af0001f73306120534.jpg

http://img2.mukewang.com/5e6920af0001554314700970.jpg

http://img2.mukewang.com/5e6920af0001ebf706020472.jpg

http://img1.mukewang.com/5e6920b00001dbd814700970.jpg

那位大哥解释下,我A1.vue,p标签要是超过1个他就报错,但是如果A1.vue只有一个p标签他就不会报错,报错代码

./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-0a4e73c0","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/components/A1.vue (Emitted value instead of an instance of Error)  Error compiling template:    <p>我是A1</p>  <p>返回上一级</p>  <p>返回首页</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. @ ./src/components/A1.vue 11:0-358 @ ./src/router/index.js @ ./src/main.js @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

提问者:宝慕林7218213 2020-03-12 01:36

个回答

  • Enernity
    2020-03-12 15:02:50
    已采纳

    把<p>标签用<div>包起来


  • 远在你的天边
    2020-03-19 09:06:23

    template里只允许存在一个父级标签

  • just冫灬
    2020-03-17 15:48:59

    语法错误

  • 宝慕林7218213
    2020-03-12 01:38:08

    不明白为什么A1.vue,p标签超过1个他就报错