uniapp底部弹出层(uni-popup)使用技巧

官网:uni-popup 弹出层 | uni-app官网 (dcloud.net.cn)

底部弹出的使用技巧工作中常用

1.一般app和小程序的弹窗都是在底部弹出,例如:

2.如何实现(简单实用)?

  •    uni-popup组件,我用vue3的时候是不用引入的,vue2需要先引入到项目中
  • 怎么使用?记得先import导入和 components注册一下, 如何从底部弹出,圆弧怎么搞?
  • 注意: import的文件位置正确,ref绑定的名称和this.$ref.后面的名称一致
<template>
	<view>
		<button @click="open">打开弹窗</button>
		<uni-popup ref="popup" type="bottom">
            <view class="test-popup">你好,底部弹出</view>
        </uni-popup>
	</view>
</template>
<script>
import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
    export default {
        components: {
			uniPopup
		},
       methods:{
          open(){
            // 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持         
            //['top','left','bottom','right','center']
            this.$refs.popup.open('bottom')//底部弹出
          }
     }
}
</script>
<style lang="scss">
    .test-popup{
        background: white;//默认全屏时灰色,只需要把你需要的部分改成白色
        border-radius: 20px;//设置弧度的大小
        height: 200px;
    }
</style>
  • 9
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值