this.program = this.program.replace(/(^s*)|(s*$)/g, ''); //去除空格; console.log('此刻的方案:',this.program) if (this.program == '' || this.program == undefined || this.program == null) { this.$message.error('不能输入为空、空格'); } ok已经替代了我之前的简单判空的方法: // if(!this.program) { //this.$message.error('请填写方案名称'); // };
let star = this.state.contentxiao.replace(/(^s*)|(s*$)/g, ""); if (star === "" || star === undefined || star === null) { // 清空输入框的值 this.setState({ contentxiao: "", }); return; }