Organize five ways to control view hiding and display in WeChat applet

1. Use the wx:if instruction

<view wx:if="{
   
   {3>2}}">我是wx:if</view>

2. Use the opacity attribute

<view style="opacity:{
   
   {opacity}}">我是opacity属性</view>

3. Use the display attribute

<view style="display:none">每个组件都有的display属性</view>//元素不显示
  
<view style="display:block">每个组件都有的display属性</view>//元素显示
  
<view hidden="{
   
   {'adfad'=='adf'}}">每个组件都有的dy属性</view>//当然在{
   
   {}}表达式中也可以使用一些简单的运算。

4. There is another way to use absolute positioning

Take the element out of the document flow and control whether the element is displayed or not by changing the element's top and left attribute values.

5. Use the hidden attribute

Control by modifying the hidden value in the js file of the page

<view hidden="true">每个组件都有的hidden属性</view>
  
<view hidden='false'>每个组件都有的hidden属性</view>
  
<view hidden="{
   
   {hiddenn}}">每个组件都有的hidden属性</view>

Guess you like

Origin blog.csdn.net/m0_74265396/article/details/132003222