修改国际化加载方式
parent
b93d6a53d1
commit
1bbd11fe80
|
@ -34,14 +34,13 @@ npm run lib-render-iview
|
|||
```
|
||||
...
|
||||
import ViewUI from 'view-design';
|
||||
import {VFormDesigner,i18n} from './{YOURPATH}/VFormDesigner.umd.min.js'
|
||||
import VFormDesigner from './{YOURPATH}/VFormDesigner.umd.min.js'
|
||||
import './{YOURPATH}/VFormDesigner.css'
|
||||
...
|
||||
Vue.use(VFormDesigner);
|
||||
Vue.use(ViewUI, {size:'small'});
|
||||
...
|
||||
new Vue({
|
||||
i18n,
|
||||
render: h => h(App)
|
||||
}).$mount('#app')
|
||||
```
|
||||
|
@ -74,14 +73,13 @@ body {
|
|||
```
|
||||
...
|
||||
import ViewUI from 'view-design';
|
||||
import {VFormRender,i18n} from './{YOURPATH}/VFormRender.umd.min.js'
|
||||
import VFormRender from './{YOURPATH}/VFormRender.umd.min.js'
|
||||
import './{YOURPATH}/VFormRender.css'
|
||||
...
|
||||
Vue.use(VFormRender);
|
||||
Vue.use(ViewUI, {size:'small'});
|
||||
...
|
||||
new Vue({
|
||||
i18n,
|
||||
render: h => h(App)
|
||||
}).$mount('#app')
|
||||
```
|
||||
|
|
|
@ -6,8 +6,6 @@ import ContainerWidget from "@/components-iview/form-designer/form-widget/contai
|
|||
import ContainerItem from "@/components-iview/form-render/container-item";
|
||||
|
||||
|
||||
import {i18n} from '@/components-iview/utils/i18n.js'
|
||||
|
||||
import '@/utils/directive'
|
||||
import '@/icons'
|
||||
import '@/iconfont/iconfont.css'
|
||||
|
@ -44,7 +42,6 @@ if (typeof window !== 'undefined' && window.Vue) { /* script方式引入时主
|
|||
|
||||
export default {
|
||||
install,
|
||||
i18n,
|
||||
VFormDesigner,
|
||||
VFormRender
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ import VFormRender from '@/components-iview/form-render/index.vue'
|
|||
import ContainerItem from "@/components-iview/form-render/container-item";
|
||||
import axios from "axios";
|
||||
|
||||
import {i18n} from '@/components-iview/utils/i18n.js'
|
||||
|
||||
VFormRender.install = function (Vue) {
|
||||
Vue.component(VFormRender.name, VFormRender)
|
||||
}
|
||||
|
@ -29,6 +27,5 @@ if (typeof window !== 'undefined' && window.Vue) { /* script方式引入时主
|
|||
|
||||
export default {
|
||||
install,
|
||||
i18n,
|
||||
VFormRender
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"serve": "vue-cli-service serve --open src/main.js",
|
||||
"serve-iview": "vue-cli-service serve --open src/main-iview.js",
|
||||
"build": "vue-cli-service build --report --dest dist/build",
|
||||
"build-iview": "vue-cli-service build --report --dest dist/build-iview",
|
||||
"build-iview": "vue-cli-service build --report --dest dist/build-iview",
|
||||
"lib": "vue-cli-service build --report --target lib --dest dist/lib --name VFormDesigner install.js",
|
||||
"lib-render": "vue-cli-service build --report --target lib --dest dist/lib-render --name VFormRender install-render.js",
|
||||
"lib-iview": "vue-cli-service build --report --target lib --dest dist/lib-iview --name VFormDesigner install-iview.js",
|
||||
|
|
|
@ -8,12 +8,8 @@ import zhLocale_render from "../lang/zh-CN_render";
|
|||
|
||||
import en from 'view-design/dist/locale/en-US';
|
||||
import zh from 'view-design/dist/locale/zh-CN';
|
||||
Vue.use(VueI18n);
|
||||
|
||||
Vue.locale = () => {};
|
||||
|
||||
Vue.locale('en-US', en);
|
||||
Vue.locale('zh-CN', zh);
|
||||
import locale from "view-design/src/locale"
|
||||
|
||||
|
||||
const langResources = {
|
||||
|
@ -29,11 +25,16 @@ const langResources = {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
Vue.use(VueI18n);
|
||||
|
||||
export const i18n = new VueI18n({
|
||||
locale: localStorage.getItem('v_form_locale') || 'zh-CN', // set locale
|
||||
messages:langResources // set locale messages
|
||||
});
|
||||
|
||||
locale.i18n((key, value) => i18n.t(key, value))
|
||||
|
||||
export const changeLocale = function(langName) {
|
||||
i18n.locale = langName
|
||||
localStorage.setItem('v_form_locale', langName)
|
||||
|
|
|
@ -14,14 +14,10 @@ import 'view-design/dist/styles/iview.css';
|
|||
import '@/styles/index.scss'
|
||||
import '@/iconfont/iconfont.css'
|
||||
|
||||
|
||||
import {i18n} from '@/components-iview/utils/i18n.js'
|
||||
|
||||
/* 递归组件如需在递归组件的嵌套组件中使用,必须注册为全局组件,原因不明?? begin */
|
||||
Vue.component('container-widget', ContainerWidget)
|
||||
Vue.component('container-item', ContainerItem)
|
||||
/* end */
|
||||
Vue.locale = () => {};
|
||||
Vue.use(ViewUI, {size:'small'});
|
||||
|
||||
|
||||
|
@ -32,7 +28,6 @@ if (typeof window !== 'undefined') {
|
|||
Vue.config.productionTip = false
|
||||
|
||||
new Vue({
|
||||
i18n,
|
||||
el: "#app",
|
||||
render: h => h(App),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue