1. 时间格式:将公历时间转换为农历时间时,安卓上可以显示,ios上无法显示
原因:ios无法识别2020-7-12中的-,转换为2020/7/12这样的格式即可
2. textarea :部分机型(oppoR9)上无法唤起输入键盘
解决:暂时先将textarea换成input
3. 异步获取数据通过遍历将数据添加到对象中,新合成的数据中有此数据,但无法渲染上此数据
let babyList = JSON.parse(JSON.stringify(res.result.data.data))
babyList.filter(item=>{
item.birthday = calAge(item.birthday)
item.isTouchMove=false
resFeedList(item._id).then(res=>{
item.photo = res
})
});
解决:使用promise.all,等所有异步任务完成再将结果抛出
Promise.all(babyList.map(item => {
return new Promise((innerResolve) => {
item.birthday = calAge(item.birthday)
item.isTouchMove = false
resFeedList(item._id).then(res => {
item.photo = res
innerResolve();
})
})
})).then(() => {
resolve(babyList);
})
4.云函数中无法通过cloud.getWXContext 获取UnionId
前置条件
- 公众号和小程序绑定在同一个公司主体下
- 在开放平台上绑定公众号,小程序
原因:在本地调试中打印cloud.getWXContext 无法获取unionid
const wxContext = cloud.getWXContext();
console.log(wxContext);
在本地调试中打印wxContext是无法看到unionid的
解决:
将wxContext返回出去,重新上传云函数,在外面打印就可以看到有unionid
(实际上unionid一直有获取到,只是在本地云函数的调试中打印是无法看到的)
ctx.data.content = wxContext;
ctx.body = { code: 200, data: ctx.data };
wx.cloud.callFunction({
name: 'login',
data: {
$url: 'addUser',
nickname: res.userInfo.nickName,
avatar: res.userInfo.avatarUrl,
albumID,
},
})
.then((res1) => {
console.log(res1);
}
})
5. vue中使用textarea ,在ios中需要点击多次才能唤起输入框
原因:项目中引入了FastClick (解决移动端延迟300毫秒的优化),当使用FastClick 时,输入框在ios上点击输入调取手机自带输入键盘不灵敏,有时候甚至点不出来。而安卓上完全没问题。这个原因是因为FastClick的点击穿透。
解决办法:在引入fastclick的js文件中加入以下代码
FastClick.prototype.focus = function (targetElement) {
let length;
if (targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
length = targetElement.value.length;
targetElement.focus();
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
};
6. 公众号发送模板消息,在开发工具上调用可以接收消息,在手机上无法接收到模板消息
原因:小程序中未配置request合法域名
解决:在微信公众平台小程序的开发设置中配置request合法域名
7. 使用toLocalString将时间戳转换为年月日时分秒
问题:在部分安卓机型上无法转换
解决:
const formatDate = (date) => {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
return [year, month, day].map(formatNumber).join('-');
};
//时分秒
const calTimestamp = (date) => {
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
let year = formatDate(date);
let time = `${year} ${[hours, minutes, seconds].map(formatNumber).join(':')}`
return time;
};
const formatNumber = (n) => {
n = n.toString();
return n[1] ? n : '0' + n;
};
输出的时间格式为
动态绑定initial-time真机上无效
initial-time="{{startTime}}"
播放到末尾时触发 ended 事件,使用VideoContext.seek()跳转到指定位置
<video id="Editvideo" src="{{showUrl}}" initial-time="{{startTime}}" object-fit="cover" loop="{{true}}" bindended="playEnd" controls="{{fasle}}" autoplay />
playEnd(){
console.log('playEnd');
this.data.VideoContext.seek(this.data.startTime);
},