uniapp-模板弹窗

思路:

1.创建静态弹窗按钮键

2.创建显示窗口【图片】

  1. <template>
  2. <view>
  3. <!-- 静态样式 -->
  4. <!-- 打开弹窗 -->
  5. <view style="padding: 200upx 15%;">
  6. <button type="primary" @tap="showBanner">打开弹窗</button>
  7. </view>
  8. <!-- 弹出层 -->
  9. <view class="uni-banner" style="background:#FFFFFF;" v-if="bannerShow">
  10. <!-- x -->
  11. <view style=" text-align:right;padding:20upx;border: 1upx solid;" @tap="closeBanner">
  12. <text>x</text>
  13. </view>
  14. <!-- 图 -->
  15. <view>
  16. <image src="https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/shuijiao.jpg" mode="widthFix" style="width:100%;"></image>
  17. </view>
  18. <!-- 按钮键 -->
  19. <view style="margin:50upx 0; margin-bottom:68upx;" >
  20. <button type='warn' style="background:#F6644D; margin:0 80upx;">一个按钮</button>
  21. </view>
  22. </view>
  23. <!-- 做黑色阴影颜色 -->
  24. <view class="uni-mask" v-if="bannerShow"></view>
  25. <!-- 弹出层 -->
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. bannerShow:true
  33. };
  34. },
  35. // 监听页面返回
  36. onBackPress() {
  37. if(this.bannerShow){
  38. this.bannerShow = false;
  39. return true;
  40. }
  41. },
  42. methods: {
  43. closeBanner:function(){
  44. this.bannerShow=false;
  45. },
  46. showBanner:function(){
  47. this.bannerShow=true;
  48. },
  49. }
  50. }
  51. </script>
  52. <style>
  53. /* 弹出层形式的广告 */
  54. .uni-banner {
  55. width: 70%;
  56. position: fixed;
  57. left: 15%;
  58. margin-top: -400upx;
  59. z-index: 99;
  60. }
  61. .uni-mask{
  62. z-index: 1;
  63. background: rgba(0, 0, 0, 0.6);
  64. }
  65. </style>
文章由官网发布,如若转载,请注明出处:https://www.veimoz.com/397
0 评论
4k

发表评论

!