在用i18n实现中英文切换的时候,出现了在表单中校验不更新的问题,尝试多种方式无果,下面这个方法值得一试。可轻松解决此问题。
data(){ ruleInline: { userName: [ { required: true, message:this.$t("insight.form.AccountEmpty"), trigger: ["change", "blur"] } ], password: [ { required: true, message:this.$t("insight.form.passwordEmpty"), trigger: ["change", "blur"] } ], identify: [{ required: true, message:this.$t("verificationCode"), trigger: "blur" }]
} }
methods: { aaa() { this.ruleInline = { userName: [ { required: true, message: this.$t("insight.form.AccountEmpty"), trigger: ["change", "blur"] } ], password: [ { required: true, message: this.$t("insight.form.passwordEmpty"), trigger: ["change", "blur"] } ], identify: [{ required: true, message: this.$t("verificationCode"), trigger: "blur" }] } } }
watch: { "$i18n.locale": function () { this.aaa(); } }, mounted() { this.aaa(); }
标签:insight,vue,required,表单,trigger,blur,i18n,message,true From: https://www.cnblogs.com/WoAiZmm/p/16918133.html