使用方式

script 中引用组件

  1. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  2. export default {
  3. components: {
  4. uniPopup,
  5. },
  6. methods:{
  7. open(){
  8. this.$refs.popup.open()
  9. }
  10. }
  11. }

template 中使用组件

  1. <button @click="open">打开弹窗</button>
  2. <uni-popup ref="popup" type="bottom">
  3. <view class="qui-card panel" style="border-radius: 20rpx 20rpx 0 0;">
  4. <view class="card-hd">
  5. <view class="tc block">
  6. <text class="fw600">分享到</text>
  7. </view>
  8. </view>
  9. <view class="card-bd">
  10. <view class="flex a-center">
  11. <view class="flex-item tc">
  12. <image class="wh100" src="/static/images/share_pyq.png" mode=""></image>
  13. <view class="mt10">朋友圈</view>
  14. </view>
  15. <view class="flex-item tc">
  16. <image class="wh100" src="/static/images/share_wx.png" mode=""></image>
  17. <view class="mt10">微信</view>
  18. </view>
  19. <view class="flex-item tc">
  20. <image class="wh100" src="/static/images/share_link.png" mode=""></image>
  21. <view class="mt10">复制链接</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view @click="closePopup('popup')" class="ptb30 tc bor-1px-t">取消</view>
  26. </view>
  27. </uni-popup>

popup.png

使用快捷的 打开和关闭 方法 ,就不用在methods自定义open方法了

@click=”openPopup(‘popup’)” // 打开
@click=”closePopup(‘popup’)” // 关闭

更多用法:
https://ext.dcloud.net.cn/plugin?id=329