uni.showToast 文字大小调整 - 如何放大领取成功提示语
如何放大 uni.showToast 中领取成功的字体大小?
使用 uni.showToast 的 duration 属性来设置显示时间,再结合 CSS 样式来改变文字大小。
- 在 CSS 中定义一个新的样式类,例如 'larger-text',设置字体大小为较大的值:
.larger-text {
font-size: 18px;
}
- 在
Confirm方法中,将 uni.showToast 方法的icon改为success,并添加一个自定义的 CSS 类 'larger-text':
Confirm() {
if (!this.othersPhone) {
this.common.UshowToast('请输入手机号');
} else {
let param = {
openId: this.openId,
storeId: this.info.storeId,
phone: this.othersPhone,
wxOrZfb: this.wxOrZfb
}
this.ajax.post(this.jk.addUser, param).then(res => {
this.showw = false;
this.$refs.popupOther.close();
if (res.status == 200) {
uni.showToast({
title: '领取成功:' + res.data.money + '元',
icon: 'success',
duration: 2000,
success: function () {
// 添加CSS样式类
setTimeout(() => {
uni.showToast({
title: '领取成功:' + res.data.money + '元',
icon: 'none',
duration: 2000,
mask: true,
image: '',
success: (res) => {},
fail: (res) => {},
complete: (res) => {}
});
}, 100);
}
})
this.user = res.data.user;
}
})
}
}
这样设置后,领取成功的文字会以较大的字体显示。
原文地址: http://www.cveoy.top/t/topic/gQZ 著作权归作者所有。请勿转载和采集!