vue或小程序关于自定义输入金额在提交前的验证——以小程序为例

// 点击立即打赏按钮
    dashang() {
      let money = (this.data.money).trim();
      if (!money || !(/^[1-9][0-9]*$/.test(money))) {
        wx.showToast({
          title: '请选择或输入正确的金额',
          icon: 'none',    //如果要纯文本,不要icon,将值设为'none'
          duration: 2000
        })
      } else {
        console.log(money);
      }
    },

你可能感兴趣的:(小程序)