当前位置:   article > 正文

uniapp的底部弹出层实现保姆式教程_uniapp底部弹窗

uniapp底部弹窗

实现照片:

此过程先进入uniapp官网,找到扩展组件

打开找到里面的uni-popup和uni-icons

点击进入,下载&安装

点击下载并导入HBuilderX

导入到你使用的目录,如test目录

同样将uni-icons点击下载并导入HBuilderX

点击合并

此时test文件夹下多了一个uni-modules文件夹

在pages下的index.vue内编写代码,如下:

  1. <template>
  2. <view>
  3. <button @click="open">打开弹窗</button>
  4. <uni-popup ref="popup" type="bottom" background-color="#fff" border-radius="10px 10px 0 0" :show="true" @close="closePopup">
  5. <view style="border-bottom: 1rpx solid #E5E5E5;padding:24rpx 0 32rpx; text-align: center;">提示</view>
  6. <view class="flex-colomn">
  7. <view class="tet">正确答案为:{{answer}}</view>
  8. <uni-icons class="close-btn" type="closeempty" size="20" @click="closePopup"></uni-icons>
  9. </view>
  10. </uni-popup>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. answer: 'A',
  18. }
  19. },
  20. methods:{
  21. open(){
  22. // 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center']
  23. this.$refs.popup.open('bottom')
  24. },
  25. closePopup() {
  26. this.$refs.popup.close()
  27. },
  28. }
  29. }
  30. </script>
  31. <style>
  32. .tet {
  33. display: flex;
  34. justify-content: center;
  35. align-items: flex-start;
  36. height: 45vh;
  37. font-size: 25px;
  38. margin-top: 20rpx;
  39. }
  40. .close-btn {
  41. position: absolute;
  42. top: 20rpx;
  43. right: 20rpx;
  44. cursor: pointer;
  45. }
  46. </style>

里面代码官网都有解释,获得底部弹出效果。

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/784283
推荐阅读
相关标签
  

闽ICP备14008679号