1.获取屏幕宽度,并赋值给view

<view class="ships-img" style="height:{{windowWidth}}px;"></view>

wx.getSystemInfo({
success: function (res) {
// console.log(res.windowWidth) 屏幕宽度
that.setData({
windowWidth: res.windowWidth
})
}
})

2.最近遇到自定义弹窗滚动问题,当文本页面过长,同时自定义弹窗也过长,即两者都需要滚动的时候,想要自定义弹窗滚动却触发的是页面的滚动。

解决思路:在打开弹窗的时候,让页面不可滚动;关闭弹窗后,恢复页面滚动。

<scroll-view scroll-y="{{isScroll}}">
<view class="rootView">
<view wx:for="{{arrayData}}" wx:key="" bindtap="showDialog" data-statu="open" class="inBoxVIew">
<text>{{item}}</text>
</view>
<!--测试弹窗-->
<view class="dialogbox" bindtap="showDialog" data-statu="close" wx:if="{{isDialogShow}}"></view>
<!--dialog-->
<view class="dialog" wx:if="{{isDialogShow}}">
<view class="windowTitle">
<text style="font-size:24px;">我是弹窗</text>
</view>
<view wx:for="{{dialogData}}" class="windowTable">
<text>{{item.name}}</text>
</view>
</view>
</view>
</scroll-view>
Page {
position: absolute;
font-size: 36rpx;
width: %;
height: %;
display: block;
background: #fff;
} scroll-view {
height: %;
}
.rootView{
padding: 10rpx;
} .inBoxVIew{
padding:20rpx ;
text-align: center;
} .dialogbox {
width: %;
height: %;
position: fixed;
top: ;
left: ;
z-index: ;
background: rgba(, , , 0.6);
overflow: hidden;
} .dialog {
width: %;
height: %;
position: fixed;
top:%;
left:%;
margin-top:-%;
margin-left:-%;
z-index: ;
background: #FAFAFA;
border-radius: 3px;
overflow-y: scroll;
} .windowTable{
width: %;
background: white;
margin: 10rpx;
padding:10rpx ;
} .windowTitle{
width: %;
text-align: center;
}
Page({

  /**
* 页面的初始数据
*/
data: {
arrayData: null,
dialogData: null,
isDialogShow: false,
isScroll: true
}, /**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) { //构建测试数据
let data = new Array();
let dialog = new Array();
for (let i = ; i < ; i++) {
data[i] = '点击我,测试' + i;
dialog[i] = {
name: '我是弹窗-' + i,
isSelected: false
};
}
this.setData({
arrayData: data,
dialogData: dialog
});
}, /**
* 显示、关闭弹窗
*/
showDialog: function (e) {
var currentStatu = e.currentTarget.dataset.statu;
console.log('currentStatu:', currentStatu);
//关闭
if (currentStatu == "close") {
this.setData({
isDialogShow: false,
isScroll: true
});
}
// 显示
if (currentStatu == "open") {
this.setData({
isDialogShow: true,
isScroll: false
});
}
}, })
 

最新文章

  1. Tween公式 以及四个参数
  2. il c井
  3. angular中自定义依赖注入的方法和decorator修饰
  4. mac os x 10.10.3 安装protoc
  5. Foundation 5 发布!最先进的响应式前端框架
  6. IO的多路复用和信号驱动
  7. Longest Increasing Common Subsequence (LICS)
  8. OpenGl从零开始之坐标变换(上)
  9. webapp调试工具weinre的使用
  10. jquery 判断页面滚动到底部
  11. 使用SuperWebSocket 构建实时 Web 应用
  12. MAC随机修改批处理
  13. ubuntu系统中crontab的使用介绍
  14. 2.熟悉Java基本类库系列——Java IO 类库
  15. 微信浏览器的页面跳转及刷新的bug
  16. spring为什么推荐使用构造器注入?
  17. Golang 微框架 Gin 简介
  18. 人工智能必须要知道的语义分割模型:DeepLabv3+
  19. 在springboot中 使用jsp
  20. Charm Bracelet(01背包问题)

热门文章

  1. 机器学习:2.NPL自然语言处理
  2. 项目中dubbo的标准配置
  3. MATLAB 和 armadillo 数据转换
  4. HTML基础—DOM操作
  5. Jenkins必备插件
  6. MongoDB与阿里云达成战略合作,最新数据库独家上线阿里云!
  7. 如何查看本机上安装的.NET Framework版本
  8. Remote desktop manager共享账号
  9. thinkphp 级联菜单实现
  10. MySQL5.7.21报错:[Err] 1055