uni——点击同一个按钮,赋予不同状态(来回切换)

案例演示:

代码:

事件源:

<view @click="open(showValue)">点击调起弹框</view>
<!-- 弹框 -->
<u-popup :show="isShow" @close="close" @open="open()" round="30rpx"></u-popup>
data() {
    
    
	return {
    
    
			isShow: false,
			// 0不显示 1显示
			showValue: 0
		}
},
method:{
    
    
	open(e) {
    
    
		if (e == 0) {
    
    
			// 如果当前不显示,那么让他显示,提前把值改掉  下一次再点的时候再进行判断
			this.isShow = true
			this.showValue = 1
		}
		if (e == 1) {
    
    
			this.isShow = false
			this.showValue = 0
		}
	},
	
	close() {
    
    
		this.isShow = false
		this.showValue = 0
	},
}

猜你喜欢

转载自blog.csdn.net/xulihua_75/article/details/128317244