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

Hiding local elements of WeChat applet

高洛峰
Release: 2018-05-15 11:05:18
Original
2586 people have browsed it

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
  }
})
Copy after login

WXML

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

WCSS

.hide{
    display:none
}
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template