您好,欢迎访问一九零五行业门户网

小结—在微信小程序开发中会遇到的一些问题

最近自己在做小程序练习,分享一下我遇到的小坑
data数据更新直接对this.data进行赋值,是无法更新视图绑定的数据的,会造成数据不一致
需要使用this.setdata更新
this.data.key = valuethis.setdata({ key: value})
require暂时不支持绝对路径
const util = require('../../utils/util.js')
background-image不能使用静态文件,只能使用base64和网络图片
可以用<img>解决
background: #fff url(data:image/jpeg;base64,***)<image class="logo" src="/images/logo.png" mode="cover"></image>
组件样式app.wxss 的样式不能应用到组件内部
可以按需引用 import: “”
@import "/app.wxss";
textareatextarea默认样式有固定宽度
事件传参模板里面事件不能传参
使用event.currenttarget.dataset获取
<view id="taptest" data-hi="wechat" bindtap="tapname"> click me! </view>page({ tapname(event) { console.log(event.currenttarget.dataset.hi) }})
animationanimation不能直接绑定中组件上
外面包裹一层<view>
<view animation={{animation}}> <my-component></my-component></view>
checkboxcheckbox-group绑定的bindchange事件,我们中点击checkbox事件会向上冒泡,导致外层也被点击
checkbox外面包一层view,给view添加一个catch事件
<checkbox-group bindchange="checkboxchange"> <view bindtap="bindtap"> <view catchtap='catchtap'"> <checkbox value="{{value}}" checked="{{checked}}"/> </view> </view></checkbox-group>
相关文章:
微信小程序 开发中遇到问题总结
微信小程序开发遇到的问题汇总
相关视频:
开发微信小程序视频教程
以上就是小结—在微信小程序开发中会遇到的一些问题的详细内容。
其它类似信息

推荐信息