Skip to content

Commit 29497ad

Browse files
authored
Update plugins.md (#658)
according to the usage of the plugin and avoid undefined errors when experimenting with the sample code, `i18n` as the initialValue of reduce() should be `options`
1 parent e2d60de commit 29497ad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/guide/plugins.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
app.config.globalProperties.$translate = key => {
4343
return key.split('.').reduce((o, i) => {
4444
if (o) return o[i]
45-
}, i18n)
45+
}, options)
4646
}
4747
}
4848
}
@@ -67,7 +67,7 @@ export default {
6767
app.config.globalProperties.$translate = key => {
6868
return key.split('.').reduce((o, i) => {
6969
if (o) return o[i]
70-
}, i18n)
70+
}, options)
7171
}
7272

7373
app.provide('i18n', options)
@@ -85,7 +85,7 @@ export default {
8585
install: (app, options) => {
8686
app.config.globalProperties.$translate = (key) => {
8787
return key.split('.')
88-
.reduce((o, i) => { if (o) return o[i] }, i18n)
88+
.reduce((o, i) => { if (o) return o[i] }, options)
8989
}
9090

9191
app.provide('i18n', options)

0 commit comments

Comments
 (0)