uni-app和小程序的那些坑——知识点汇总

zhuanbike 2022-4-6 877

1、换行,小程序不支持<br>

要使用\n

2、提示框,不支持alert

uni.showToast({

 title: '提示信息!',

 icon: 'none',

 duration: 5000

});

3、空格

关于文档中的 space属性大家想用的话可以记一下,但是我们查文档的时间可能想用更鸡贼的方法——

{{' '}}

用这种方式可能不是很地道,但是能快速解决问题。

4、一键呼出电话

与wx.makePhoneCall类似

tophone(data = this.telephone){

uni.makePhoneCall({

        phoneNumber:data

       })

},

5、自写时间戳转换器

没自带时间戳转化,直接写fillter

{item.time|formatDate}}

js部分 直接卸载js顶层标签,不要嵌套method

//时间戳转化

filters: {

formatDate: function(value) {

let date = new Date();

//date.setTime(value);

let month = date.getMonth() + 1;

let hours = date.getHours();

if (hours < 10)

hours = "0" + hours;

let minutes = date.getMinutes();

if (minutes < 10)

minutes = "0" + minutes;

let time = date.getFullYear() + "年" + month + "月" + date.getDate() +

"日";

// + hours + ":" + minutes

return time;

}

},





最新回复 (0)
发新帖