···
<view class="example-body">
<view class="word-btn draw-cotrol-btn" hover-class="word-btn--hover" :hover-start-time="20" :hover-stay-time="70" @click="showDrawer('showRight')"><text class="word-btn-white">显示Drawer</text></view>
<uni-drawer ref="showRight" mode="right" :mask-click="false" @change="change($event,'showRight')">
<view class="scroll-view">
<scroll-view class="scroll-view-box" scroll-y="true">
<view class="info">
<text class="info-text">右侧遮罩只能通过按钮关闭,不能通过点击遮罩关闭</text>
</view>
<view class="close">
<view class="word-btn" hover-class="word-btn--hover" :hover-start-time="20" :hover-stay-time="70" @click="closeDrawer('showRight')"><text class="word-btn-white">关闭Drawer</text></view>
</view>
<view class="info-content" v-for="item in 100" :key="item">
<text>可滚动内容 {{item}}</text>
</view>
<view class="close">
<view class="word-btn" hover-class="word-btn--hover" :hover-start-time="20" :hover-stay-time="70" @click="closeDrawer('showRight')"><text class="word-btn-white">关闭Drawer</text></view>
</view>
</scroll-view>
</view>
</uni-drawer>
</view>
<script>
export default {
data() {
return {
showRight: false,
showLeft: false
}
},
methods: {
confirm() {},
// 打开窗口
showDrawer(e) {
this.$refs[e].open()
},
// 关闭窗口
closeDrawer(e) {
this.$refs[e].close()
},
// 抽屉状态发生变化触发
change(e, type) {
console.log((type === 'showLeft' ? '左窗口' : '右窗口') + (e ? '打开' : '关闭'));
this[type] = e
}
},
onNavigationBarButtonTap(e) {
if (this.showLeft) {
this.$refs.showLeft.close()
} else {
this.$refs.showLeft.open()
}
},
// app端拦截返回事件 ,仅app端生效
onBackPress() {
if (this.showRight || this.showLeft) {
this.$refs.showLeft.close()
this.$refs.showRight.close()
return true
}
}
}
</script>
···