记录下小程序开发过程中遇到的一些问题以及解决方案 记录下小程序开发过程中遇到的一些问题以及解决方案 原文 链接 1. 微信开发者 1.0.0 版本 GET1351598279.appservice.open.weixin.qq.com/apps
记录下小程序开发过程中遇到的一些问题以及解决方案 记录下小程序开发过程中遇到的一些问题以及解决方案 原文链接 1. 微信开发者 1.0.0 版本GET 1351598279.appservice.open.weixin.qq.com/appservice net::ERR_NAME_NOT_RESOLVED 解决办法公司的网络是翻墙网络,微信应该是给禁掉了 设置-----> 代理设置 -----> 不适用任何代理,勾选直联网络 2. 对应的服务器证书无效。控制台输入 showRequestInfo() 可以获取更详细信息解决办法
小程序数据请求必须是 3. 按条件设置class
<text wx:for="{% raw %}{{titles}}{% endraw %}"
wx:key="{% raw %}{{item}}{% endraw %}"
class="home-title {% raw %}{{index == activeIndex ? 'active' : ''}}{% endraw %}"
bindtap='changeClassify'>
{% raw %}{{item.name}}{% endraw %}
</text>
// index == activeIndex classw为 "home-title active" 否则为 "home-title "
4.循环嵌套
// 普通的单次循环
<text wx:for="{% raw %}{{titles}}{% endraw %}" wx:key="{% raw %}{{index}}{% endraw %}">{% raw %}{{item.name}}{% endraw %}</text>
//循环嵌套时使用 wx:for-item="XXX"
<view wx:for="{% raw %}{{hotArr}}{% endraw %}">
<view class="classify-title" bindtap="goClassifyPage">
<text>{% raw %}{{item.name}}{% endraw %}</text>
</view>
<view class="classify-items">
<view class="classify-item" wx:for=">{% raw %}{{item.data}}{% endraw %}" wx:for-item="cell" wx:key="index">
<view>
<text class="classify-item_name">{% raw %}{{cell.name}}{% endraw %}</text>
</view>
</view>
</view>
</view>
5. router 跳转传参及参数获取
//wxml
<text wx:for="{% raw %}{{titles}}{% endraw %}" wx:key="{% raw %}{{index}}{% endraw %}" bindtap='changeClassify' data-id="{% raw %}{{index}}{% endraw %}">{% raw %}{{item.name}}{% endraw %}</text>
//js
function changeClassify(e) {
//
let id = e.currentTarget.dataset.id;
//跳转到classify 页面
wx.navigateTo({
url: '../classify/classify?id=' + id
})
}
//classify 页面 获取参数
onLoad: function (opts) {
console.log(opts.id)
console.log(this.options.id)
}
// index == activeIndex classw为 "home-title active" 否则为 "home-title "
6. 上拉加载更多, 下拉刷新
// 上拉加载更多
onReachBottom: function() {
if (this.data.next != null) {
this.setData({ isHideLoadMore: false })
this.getNextPage()
}
}
// 下拉刷新
onPullDownRefresh: function() {
this.refreshData()
}
7. 组件化
|