Commit 54f510c5289154c78899b3d317cd989ab360aa12
1 parent
1cbdb617
fixed not support Nuxt.js
Showing
2 changed files
with
17 additions
and
4 deletions
Show diff stats
build/webpack.dist.locale.config.js
@@ -22,6 +22,14 @@ module.exports = { | @@ -22,6 +22,14 @@ module.exports = { | ||
22 | libraryTarget: 'umd', | 22 | libraryTarget: 'umd', |
23 | umdNamedDefine: true | 23 | umdNamedDefine: true |
24 | }, | 24 | }, |
25 | + externals: { | ||
26 | + vue: { | ||
27 | + root: 'Vue', | ||
28 | + commonjs: 'vue', | ||
29 | + commonjs2: 'vue', | ||
30 | + amd: 'vue' | ||
31 | + } | ||
32 | + }, | ||
25 | plugins: [ | 33 | plugins: [ |
26 | new webpack.DefinePlugin({ | 34 | new webpack.DefinePlugin({ |
27 | 'process.env': { | 35 | 'process.env': { |
src/locale/lang.js
1 | // using with vue-i18n in CDN | 1 | // using with vue-i18n in CDN |
2 | /*eslint-disable */ | 2 | /*eslint-disable */ |
3 | +import Vue from 'vue'; | ||
4 | +const isServer = Vue.prototype.$isServer; | ||
5 | + | ||
3 | export default function (lang) { | 6 | export default function (lang) { |
4 | - if (typeof window.iview !== 'undefined') { | ||
5 | - if (!('langs' in iview)) { | ||
6 | - iview.langs = {}; | 7 | + if (!isServer) { |
8 | + if (typeof window.iview !== 'undefined') { | ||
9 | + if (!('langs' in iview)) { | ||
10 | + iview.langs = {}; | ||
11 | + } | ||
12 | + iview.langs[lang.i.locale] = lang; | ||
7 | } | 13 | } |
8 | - iview.langs[lang.i.locale] = lang; | ||
9 | } | 14 | } |
10 | }; | 15 | }; |
11 | /*eslint-enable */ | 16 | /*eslint-enable */ |
12 | \ No newline at end of file | 17 | \ No newline at end of file |