如何放大 uni.showToast 中领取成功的字体大小?

使用 uni.showToast 的 duration 属性来设置显示时间,再结合 CSS 样式来改变文字大小。

  1. 在 CSS 中定义一个新的样式类,例如 'larger-text',设置字体大小为较大的值:
.larger-text {
  font-size: 18px;
}
  1. 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;
      }
    })
  }
}

这样设置后,领取成功的文字会以较大的字体显示。

uni.showToast 文字大小调整 - 如何放大领取成功提示语

原文地址: http://www.cveoy.top/t/topic/gQZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录