vue(uni-app)报错:Component template should contain exactly one root element.

深藏阁楼爱情的钟 2022-12-07 12:29 323阅读 0赞

报错信息如下:
在这里插入图片描述
代码片段如下:

  1. <template>
  2. <view class="status_bar">
  3. <view class="top_view"></view>
  4. </view>
  5. <view class="top_nav">
  6. <text>移动平台</text>
  7. </view>
  8. </template>

原因:vue模板只能有一个根对象
用一个标签包裹住全部元素即可,如下:

  1. <template>
  2. <view class="">
  3. <view class="status_bar">
  4. <view class="top_view"></view>
  5. </view>
  6. <view class="top_nav">
  7. <text>移动平台</text>
  8. </view>
  9. </view>
  10. </template>

发表评论

表情:
评论列表 (有 0 条评论,323人围观)

还没有评论,来说两句吧...

相关阅读