uni-app踩坑一 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、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.

uni-app在每个page页中只能有一个根元素,与vue的模版template一样

正确示范:

<template>
	<view>
		<view v-if="title==1">
			{{time.one}}
		</view>
		<view v-else>
			{{time.two}}
		</view>
		<view>
			{{time.three}}
		</view>
	</view>
</template>

  错误示范:

<template>
        <view v-if="title==1">
            {{time.one}}
        </view>
        <view v-else>
            {{time.two}}
        </view>
        <view>
            {{time.three}}
        </view>
</template>

猜你喜欢

转载自www.cnblogs.com/black-xj/p/11608384.html