AI助手支持GPT4.0
关于条件渲染中wx:if使用的问题?About the use of wx:if in conditional rendering?
关于条件渲染中wx:if使用的问题?
在官方文档中有这个例子,最终显示结果为3。
<view wx:if="{{length > 5}}"> 1 </view><view wx:elif="{{length > 2}}"> 2 </view><view wx:else> 3 </view>
我自己写成这样:
<view wx:if="{{length > 5}}"> 10 </view>
<view wx:elif="{{length > 2}}"> 4 </view>
<view wx:else> 3 </view>
我觉得结果应该显示为:10 4 3,但是结果还是显示3。这是什么原因啊?
第一条件10满足大于5的要求,
第二个条件4满足大于2小于等于5的要求
第三个条件满足小于等于5的要求。
三个要求都满足,为什么只显示最后一个条件3呢?
There is this example in the official document, and the final result is 3< View Wx: if = "{length > 5}}" > 1 < / View > < view Wx: elif = "{length > 2}}" > 2 < / View > < view Wx: else > 3 < / View > I wrote it myself: < view Wx: if = "{length > 5}}" > 10 < / View > < view Wx: elif = "{length > 2}}" > 4 < / View > < view Wx: else > 3 < / View > I think the result should be displayed as: 10 4 3, but the result still displays 3. What's the reason? The first condition 10 meets the requirements of greater than 5, the second condition 4 meets the requirements of greater than 2 and less than or equal to 5, and the third condition meets the requirements of less than or equal to 5. If all three requirements are met, why only the last condition 3 is displayed?