跳转tabBar页面时,不能使用navigator标签、 wx.navigateTo、wx.redirectTo方法跳转页面,可以使用wx.switchTab(Object object)和wx.reLaunch(Object object)
延时执行
setTimeout(function(){
console.log("延时1秒后执行");
}, 1000);
wxss中的本地资源图片无法通过 WXSS 获取,可以使用网络图片,或者 base64,或者使用标签。
自定义导航栏
"navigationStyle":"custom"
"renderer": "skyline",
border-radius设置失效:给container元素添加overflow: hidden 或 transform: translateY(0)
是图片充满容器
<view class="location-img"><image src="" mode=""/></view>
//设置:
img{
width:100%;
height:100%
}
注意 e.currentTarget.dataset.value 和 e.targetarget.dataset.value
success不能使用this.setData
var that=this //然后that.setData
报错:No primary or single unique constructor found for interface java.util.List
//添加
(@RequestParam(value = "arr") List<Integer> arr)
wx.getLocation({})不执行
//在app.json中添加
"requiredPrivateInfos": [
"getLocation"
],
小程序做删除的时候,请求用的是delete时,按平时做GET,POST时的方式传参,后台是接收不到参数的。原因是因为传的是json格式,但是delete接口要的是query string格式的,所以就导致参数传过去,后端无法接收。 PUT也是
解决方法:
//1.手动拼接
wx.request({
url: 'http://localhost:8080/personalinfo/delete?id='+that.data.personalInfo.id, //手动拼接
method: 'DELETE',
data: {
},
header: { 'content-type': 'application/json' },
success(res) {
}
})
//2.content-type用formData的
wx.request({
url: "http://test/xxx",
method:'DELETE',
data:{id},
header:{
"content-type":"application/x-www-form-urlencoded"
},
解决swiper轮播图不能占满
swiper {
width: 100%;
height: calc(100vw * 327 / 491);
}
image {
width: 100%;
}
解决switchTab数据不刷新 switchTab成功跳转后调用success,此时可以拿到跳转后页面的page对象,从而调用页面onLoad方法重载页面;微信后期应该会加相应的参数来决定是否刷新跳转
wx.switchTab({
url: ‘../index/index’,
success: function (e) {
var page = getCurrentPages().pop();
if (page == undefined || page == null) return;
page.onLoad();
}
})
获取当前时间
const now = new Date();
const year = now.getFullYear();
const month = this.formatNumber(now.getMonth() + 1);
const day = this.formatNumber(now.getDate());
const hours = this.formatNumber(now.getHours());
const minutes = this.formatNumber(now.getMinutes());
const currentTime = `${year}-${month}-${day} ${hours}:${minutes}`;
this.setData({
time: currentTime
});
formatNumber(n) {
n = n.toString();
return n[1] ? n : '0' + n;
},