ESLint
报错:异常:TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter (<anonymous>:3:28)]
vue3默认创建,会使用ESLint,也就是开启了严格模式。
两种解决方式:
-
关闭ESLint
在vue.config.js中加入
module.exports = defineConfig({ lintOnSave: false })
-
遵守ESLint语法。
比如我的代码:
const validatePassword = (rule, value) => { console.log(value.value); if (!value) { return '密码不能为空'; } if (!/\d/.test(value) || !/[a-zA-Z]/.test(value)) { return '密码必须包含至少一个数字和一个字母'; } if (value.length < 6) { return '密码长度至少为6位'; } return true; };
rule未使用,因此会报错。我的解决是去掉了rule参数。