inputValidator规定校验函数,可以返回Boolean或String,返回false或字符串时均表示校验未通过,同时返回的字符串相当于定义了inputErrorMessage字段。
this.$prompt('请输入', '新增标签', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputValidator: (value) => {
if (value) {
return true
} else {
return '请输入标签'
}
},
inputPlaceholder: '请输入标签'
}).then(({ value }) => {
if (value) {
console.log("查看输入", value)
}
}).catch(() => {
this.$message({
type: 'info',
message: '取消新增标签'
})
})