mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 22:49:15 +08:00
[Improvement] Locale: add warning when not correctly registered (#1012)
This commit is contained in:
parent
533092e87f
commit
883fb78f21
@ -6,8 +6,13 @@ export default {
|
||||
$t() {
|
||||
const { name } = this.$options;
|
||||
const prefix = name ? camelize(name) + '.' : '';
|
||||
const messages = this.$vantMessages[this.$vantLang];
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !this.$vantMessages) {
|
||||
console.warn('[Vant] Locale not correctly registered.');
|
||||
return () => '';
|
||||
}
|
||||
|
||||
const messages = this.$vantMessages[this.$vantLang];
|
||||
return (path, ...args) => {
|
||||
const message = get(messages, prefix + path) || get(messages, path);
|
||||
return typeof message === 'function' ? message.apply(null, args) : message;
|
||||
|
Loading…
x
Reference in New Issue
Block a user