微信小程序问题集合
app.json
error:expected common json
添加page时少了一个逗号
wx:if
<image class="ending" wx:if="{{judg}}" src="{{fail}}"></image>
<image class="ending" wx:else src="{{success}}"></image>
getCurrentPages().pop();
wx.navigateTo({
url: '/pages/bridge/fail?judge=true',
});
传递judge为布尔值时,wx:if wx:else的判断总是出错
后将judge改为int类型,传递judge=1/2,判断==1
swiper组件
bindanimationfinish函数说明为:动画结束时会触发 animationfinish 事件。
但轮播还未结束时该函数就被调用。
autoplay="{{auto}}"
通过js修改auto外加其他函数完成。
CSS
margin,padding 百分比是按父元素的宽度来计算。
js
error:cannot read property of undefined
在for(i;i<num;i++)循环中修改了num,导致数组下标越界。
setTimeout
that.fail();
setTimeout(function(){
},3000);
getCurrentPages().pop();
wx.navigateTo({
url: '/pages/bridge/fail?judge=1',
});
settimeout还未结束时,页面已经跳转,settimeoutt没有相应的延迟。
后改为:
that.fail();
setTimeout(function(){
getCurrentPages().pop();
wx.navigateTo({
url: '/pages/bridge/fail?judge=1',
});
},3000);