Home >WeChat Applet >Mini Program Development >Hiding local elements of WeChat applet

Hiding local elements of WeChat applet

高洛峰
高洛峰Original
2018-05-15 11:05:182596browse

Sometimes we want certain elements on the page to appear at specific times, so we need to use the hiding function of local elements.
Here is a way to use flag bits to hide or switch local elements.

The main function of the following code is: click first to hide the first view and display the second one. Click second to hide the second view and display the first one.
JS Code

Page({
  data:{
      flag:0
  },
  clickMes1: function(){
      falg=1
  } ,
  clickMes2: function(){
      falg=1
  }
})

WXML

<view class={{flag===0?"hide":""}} bindtap="clickMes1">first </view>
<view class={{flag===1?"hide":""}} bindtap="clickMes2">second</view>
1
2

WCSS

.hide{
    display:none
}

For more articles related to hiding local elements of WeChat mini programs, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn