uni-app组件uni-drawer 小案例(不遮挡小程序自定义导航栏)

效果展示:

 

直接上代码: 

<template>
    <view>
        <unidrawer ref="draw" :mask="mask" :width="drawWid" :mode='mode' >
            <view style="padding:30rpx;">
                <view class="uni-title">抽屉式导航</view>
            </view>
            <button type="warn" @tap="hide()" style="margin-top: 100rpx;">关闭</button>
        </unidrawer>
        <button type="primary" @tap="show()">显示</button>
    </view>
</template>
<script>
    import unidrawer from "@/uni_modules/uni-drawer/components/uni-drawer/uni-drawer.vue"
	const res = wx.getSystemInfoSync();
	const statusHeight = res.statusBarHeight; //状态栏高度
	const cusnavbarheight = (statusHeight + 44) + "px";
    export default {
        components: {unidrawer},
        data() {
            return {
                mask: true,
                left:'left',
                drawWid:'50%',//需要把uni-drawer组件里的参数width的type改为String,我这里是第63 64行
                maskClick:true,
                mode:'left'
            };
        },
        methods: {
            //显示抽屉
            show(){
                this.$refs.draw.open();
            },
            hide(){
                this.$refs.draw.close();
            }
        }
    }
</script>

<style scoped lang="scss">
  ::v-deep .uni-drawer {
    margin-top: v-bind(cusnavbarheight)
  }
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值