小程序开发问题
数据内容换行:
1. 必须在text标签内 2. \n换行,\rEnter, \t空格
导航页面跳转传参:
方法:通过Page中的onLoad自动接收参数
<view class="btn-area"> <navigator url="/page/navigate/navigate?title=navigate" hover-class="navigator-hover">跳转到新页面</navigator> <navigator url="../../redirect/redirect/redirect?title=redirect" open-type="redirect" hover-class="other-navigator-hover">在当前页打开</navigator> <navigator url="/page/index/index" open-type="switchTab" hover-class="other-navigator-hover">切换 Tab</navigator> </view> Page({ onLoad: function(options) { this.setData({ title: options.title }) } })
wx.request里的this不指向外部:
onLoad (options) { let that = this wx.request({ url: app.config.host + '/weiphp/index.php?s=/w16/Cms/Cms/getDetail', data: {id: options.id}, success (res) { that.setData({info: res.data}) // console.log(res.data) } }) }
域名问题:
1. 使用安全域: 必须为被认证的已备案的域名,在小程序后台中设置 2. 使用非安全域: 开发阶段可以使用未校验的域名访问方式,在微信开发者工具中进行设置