Vue: <br>or<hr>==>Error compiling template?

Created on 30 Mar 2017  ·  2Comments  ·  Source: vuejs/vue

Version

2.2.6

Reproduction link

https://github.com/vuejs/vue/issues/5331

Steps to reproduce

<template id="page-footer-template">
    <br />
    <div>
      <h1>hello,world</h1>
    </div>
    <hr />
</template>

What is expected?

hello,world

What is actually happening?

Error compiling 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.

Most helpful comment

Component template should contain exactly one root element.

@yijunjun Try

<template id="page-footer-template">
    <div>
      <br />
      <div>
            <h1>hello,world</h1>
       </div>
       <hr />
   </div>
</template>

All 2 comments

你是看不懂英文吗?Read the error message please.

Component template should contain exactly one root element.

@yijunjun Try

<template id="page-footer-template">
    <div>
      <br />
      <div>
            <h1>hello,world</h1>
       </div>
       <hr />
   </div>
</template>

Was this page helpful?
0 / 5 - 0 ratings