程序中 popupwindow 弹出框实现代码的详细介绍

why 168 2024-08-02

本篇文章给大家带来的内容是关于小程序popupwindow弹出框的实现代码,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

在上方弹出

20180905112059739.gif

wxml

1

2

3

4

5

<view class="zan-dialog {{ showDialog ? &#39;zan-dialog--show&#39; : &#39;&#39; }}">

  <view class="zan-dialog__mask" bindtap="toggleDialog" />

  <view class="zan-dialog__container">

    <view style="padding: 100px 0; text-align: center;">Dialog内容</view>

  </view></view>

wcss

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

.zan-dialog__mask {

  position: fixed; 

  top: 0;  left: 0; 

  right: 0; 

  bottom: 0; 

  z-index: 10; 

  background: rgba(0, 0, 0, 0.4); 

  display: none;

  }

.zan-dialog__container {

  position: fixed; 

  top: 0; 

  width: 750rpx; 

  background: white; 

  transform: translateY(-150%); 

  transition: all 0.4s ease; 

  z-index: 12;

  }

.zan-dialog--show .zan-dialog__container {

  transform: translateY(0);

  }

.zan-dialog--show .zan-dialog__mask {

  display: block;

  }

js

1

2

3

4

5

6

7

8

9

10

Page({  data: {    showDialog: false

  },//控制 pop 的打开关闭

  toggleDialog() {

    this.setData({

      showDialog: !this.data.showDialog

    });

 

  },

 

})

在下方弹出

wxml

1

2

3

4

5

6

<view class="zan-dialog {{ showDialog ? &#39;zan-dialog--show&#39; : &#39;&#39; }}">

  <view class="zan-dialog__mask" bindtap="toggleDialog" />

  <view class="zan-dialog__container">

    <view style="padding: 100px 0; text-align: center;">Dialog内容</view>

  </view>

</view>

wcss

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

.zan-dialog__mask {

  position: fixed

  top: 0

  left: 0

  right: 0

  bottom: 0

  z-index: 10

  background: rgba(0, 0, 0, 0.4); 

  display: none;

  }

.zan-dialog__container {

  position: fixed

  bottom: 0

  width: 750rpx; 

  background: white

  transform: translateY(150%); 

  transition: all 0.4s ease; 

  z-index: 12;

  }

.zan-dialog--show .zan-dialog__container {

  transform: translateY(0);

  }

.zan-dialog--show .zan-dialog__mask {

  display: block;

  }

js

1

2

3

4

5

6

7

8

9

10

Page({  data: {    showDialog: false

  },//控制 pop 的打开关闭

  toggleDialog() {

    this.setData({

      showDialog: !this.data.showDialog

    });

 

  },

 

})

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序中自定义分享按钮的实现流程详解
下一篇:小程序中 canvas 拖拽功能的详细解析与说明
相关文章

 发表评论

暂时没有评论,来抢沙发吧~