[WeChat Mini Program] The difference between wx:if and hidden

Similarities and differences between wx:if and hidden in WeChat applet


id name Same point difference
0 wx:if Display when true, not display false,都可以控制元素是否展示 When true, the element falseis in the view and displayed, when the element is not in the view,被销毁
1 hidden Hide when true, display false,都可以控制元素是否展示 When the false and true, the view has that element, however, is truewhen, 隐藏up

Insert picture description here

Insert picture description here

  • Summary: Using hidden, no matter the value is true or false, the element will be loaded, wx:if, only when it is true, will it be loaded.所以,可以在切换频率较少的时候使用wx:if,减少资源的使用, 切换较多的地方使用hidden,提高用户体验.

Guess you like

Origin blog.csdn.net/weixin_40944062/article/details/105341341