1.避免多次点击
某些情况下,避免不了有些手速过快的客户,如何避免点击一次触发多次接口的情况?
data() {
isClick:false,// 在data里面定义一个变量,这里表示是否点击提交过
},
method(){
xxx(){
if(this.isClick){
uni.showToast({
title:'数据处理中...'
})
return;
}
this.isClick =true;
xxx.().then((res)=>{
this.isClick =false;
)}
}
}
2.页面刷新
onShow和onLoad的区别:
- onLoad:页面加载时触发,一个页面只会调用一次。
- onShow: 页面显示/切入前台时触发。
onLoad/onShow: function(options) {
this.xxx();
setTimeout(function() {
uni.startPullDownRefresh();
}, 10);
},
onPullDownRefresh() {
this.xxx();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 10);
},
3.万水千山总是情,打个电话行不行?
<view @click="xxx">热线: {{xxxxx}}</view>
xxx() {
if (this.serviceTelNo != null) {
uni.makePhoneCall({
// 手机号
phoneNumber: this.xxxxx + '',
// 成功回调
success: (res) => {
// console.log('调用成功!')
},
// 失败回调
fail: (res) => {
// console.log(res);
// console.log('调用失败!')
}
});
}
},
4.滚动区高度
computed: {
// 滚动区高度
scrollerHeight: function() {
let screenHeight = my.xxxxxxxxx().windowHeight
return (screenHeight-350) + 'px'; //自定义高度需求
}
},