uniapp 报错 “Component template should contain exactly one root element.“解决方案

在uniapp中遇到自定义组件引入时出现'Component template should contain exactly one root element.'的报错。错误提示表明组件模板需要且仅能有一个根元素。通常建议使用v-if和v-else-if进行条件判断来确保只有一个根节点。但实际需求可能不允许这样操作。一种可能的解决方案是在组件内部,通过添加一个view元素将所有内容包裹起来,以满足单根节点的要求。
摘要由CSDN通过智能技术生成

uniapp 引入自定义组件的时候报错

报错信息: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.

<template>
	<view>
		<z-comm :commodity="commodity"></z-comm>
		<view class="fence">
			<view class="fenceItem">
				<view class="label">退款金额:</view>
				<view class="price">¥ {
  {commodity.price}}</view>
			</view>
			<view class="fenceItem">
				<view class="label">退款原因:</view>
				<input type="text" class="reason" placeholder="必填"></view>
			</view>
		</view>
		<view class="fence">
			<view class="fenceItem">上传凭证:</view>
			<view class="fenceItem">
				<image class
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值