zl程序教程

您现在的位置是:首页 >  其他

当前栏目

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

状态 不同 切换 点击 按钮 uni 同一个 赋予
2023-09-14 09:04:08 时间

案例演示:

代码:

事件源:

<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
	},
}