在浏览器中打断点发现会执行两次这个函数,第一次验证的时候没有任何问题,正常请求接口,但是不知道为什么会执行第二次。
import { checkCode } from "@/api/sales/globalWares";
var checkCode = (rule, value, callback) => {
if (!value) {
callback(new Error('请输入编码'));
} else {
checkCode({ waresCode: value }).then(res => {
if (res.data > 0) {
callback(new Error('编码重复'));
} else {
callback();
}
});
}
}
rules: {
waresCode: [
{ required: true, validator: checkCode, trigger: 'blur' }
],
shortName: [
{ required: true, message: "商品简称不能为空", trigger: "blur" }
]
},
vue.runtime.esm.js:1888 TypeError: callback is not a function
at checkCode (index.vue?76f2:171)
at Object.checkCode [as validator] (index.vue?76f2:173)
at index.js:216
at next (util.js:114)
at asyncSerialArray (util.js:120)
at util.js:154
at Array.forEach (<anonymous>)
at asyncMap (util.js:151)
at Schema.validate (index.js:141)
at VueComponent.validate (element-ui.common.js:23501)
logError @ vue.runtime.esm.js:1888
globalHandleError @ vue.runtime.esm.js:1879
handleError @ vue.runtime.esm.js:1839
invokeWithErrorHandling @ vue.runtime.esm.js:1862
Vue.$emit @ vue.runtime.esm.js:3882
dispatch @ emitter.js:29
handleBlur @ element-ui.common.js:4811
invokeWithErrorHandling @ vue.runtime.esm.js:1854
invoker @ vue.runtime.esm.js:2179
original._wrapper @ vue.runtime.esm.js:6911
验证部分代码就是这样的,不知道有没有哪位大佬能帮忙解答一下。。。
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…