微信小程序常见异常

微信小程序常见异常

1.查找数据时,条件中ReferenceError: _ is not defined

添加如下代码定义下划线

const _ = db.command

2.this.data和this.setData不生效

1.onload 等方法中不在可以使用data直接赋值,需要调用setData方法(原因待查找)

2.setData不生效可能你的this不正确,也可能你的设置的值有问题,我的就是在callback中使用出错

this.setData({
list:res
})

应为

this.setData({
list:res.data
})

3.悬浮按钮覆盖内容

页面尾部追加相同内容的非悬浮隐藏版本即可.

示例代码:wxml部分
<!-- 隐藏占空间按钮,为使内容正常显示出来,避免被覆盖 -->
<view class="oneLine hidden">
    <button class="bottom_button" bindtap="loadLastPage">上一页</button>
    <button class="bottom_button" bindtap="loadNextPage">下一页</button>
  </view>
  <!-- 底部悬浮显示按钮 -->
  <view class="oneLine bottom">
    <button class="bottom_button" bindtap="loadLastPage">上一页</button>
    <button class="bottom_button" bindtap="loadNextPage">下一页</button>
  </view>
示例代码:wxss部分
.bottom {
  width: 100%;
  position: fixed;
  bottom: 0;
}

.hidden{
  visibility: hidden;
}

.bottom_button {
  background-color: seagreen;
}

.oneLine {
  /* display: inline; */
  display: flex;
}

}

.oneLine {
/* display: inline; */
display: flex;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值