条件渲染-条件成立时组件才能渲染
wx:if
wx:if vs hidden
需求:博主强烈推荐的电影,显示出红色标记。
<view class="container">
<text>本周推荐</text>
<image class="about-banner"
src="{{thisWeekMovie.imagePath}}">
</image>
<text style="font-weight:bold;font-size:60rpx">{{thisWeekMovie.name}}</text>
<text>点评:{{thisWeekMovie.comment}}</text>
<text wx:if="{{thisWeekMovie. isHighRecommended}}"style="font-size:16px;color:red;">强烈推荐</text>
</view>
Page({
data:{
thisWeekMovie:{
name:"瓶子",
comment:"最精彩的剧本,最真实的生活电影",
imagePath:"http://t8.baidu.com/it/u=3571592872,3353494284&fm=79&app=86&f=JPEG?w=1200&h=1290",
isHighRecommended:true
}
}