diff --git a/docs/2.0.0/actionSheet.md b/docs/2.0.0/actionSheet.md
index f0df0a72..23421282 100755
--- a/docs/2.0.0/actionSheet.md
+++ b/docs/2.0.0/actionSheet.md
@@ -20,40 +20,7 @@
```
:::
-``` js
-export default {
- data() {
- return {
- visible1: false,
- visible2: false,
- visible3: false,
- actions1: [{
- text: '操作一',
- onClick: () => console.log('action 1'),
- },{
- text: '操作二',
- onClick: () => console.log('action 2'),
- },{
- theme: 'error',
- text: '操作三',
- onClick: () => console.log('action 3'),
- }],
- actions2: [{
- text: '操作一',
- onClick: () => console.log('action 1'),
- },{
- text: '操作二',
- onClick: () => console.log('action 2'),
- }],
- }
- },
- methods: {
- cancelCb(reason, event){
- console.log(reason, event)
- }
- },
-};
-```
+
### Vue Script
```javascript
+```
+
## API
| 属性 | 类型 | 默认值 | 说明 |
| :--- | :--- | :--- | :--- |
-| locale | Object | - | 语言包配置,语言包可到 zarm-vue/lib/locale-provider/locale 目录下寻找 |
\ No newline at end of file
+| locale | Object | - | 语言包配置 |
+| lang | String | - | 设置语言包类型,对应locale的key值 |
\ No newline at end of file
diff --git a/package.json b/package.json
index 593e11de..71a33ecd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "zarm-vue",
- "version": "2.0.0-alpha.7",
+ "version": "2.0.0-alpha.8",
"description": "zarm in vue",
"tags": [
"zarm",
diff --git a/site/store/index.js b/site/store/index.js
index 7dd9acd4..bedcbf08 100644
--- a/site/store/index.js
+++ b/site/store/index.js
@@ -19,7 +19,7 @@ const store = new Vuex.Store({
path: 'https://chuanshuoye.github.io/zarm-vue-doc/#/zh-CN'
},{
value: '2.0.0',
- label: '2.0.0-alpha.7',
+ label: '2.0.0-alpha.8',
path: '#/documents/quick-start'
}]
},
diff --git a/src/alert/src/alert.vue b/src/alert/src/alert.vue
index 336f889e..b3702f7b 100644
--- a/src/alert/src/alert.vue
+++ b/src/alert/src/alert.vue
@@ -5,7 +5,7 @@
- {{cancelBtnText}}
+ {{cancelText || cancelBtnText}}
@@ -52,13 +52,13 @@ export default {
},
computed: {
cancelBtnText() {
- return this.cancelText || this.getLocales('cancelText') || '关闭';
+ return this.localeProvider.lang ? this.getLocales('cancelText') : '关闭';
},
},
methods: {
// 国际化
getLocales(key) {
- return Locale.getLocaleByComponent(this, 'Alert', key);
+ return Locale.getLocaleByComponent(this.localeProvider, 'Alert', key);
},
handleClose(event) {
this.$refs.modal.leave('modal-close', event);
diff --git a/src/confirm/src/confirm.vue b/src/confirm/src/confirm.vue
index d24cff95..73e5bed1 100644
--- a/src/confirm/src/confirm.vue
+++ b/src/confirm/src/confirm.vue
@@ -5,8 +5,8 @@
- {{cancelBtnText}}
- {{okBtnText}}
+ {{cancelText || cancelBtnText}}
+ {{okText || okBtnText}}
@@ -65,10 +65,10 @@ export default {
},
computed: {
cancelBtnText() {
- return this.cancelText || this.getLocales('cancelText') || '关闭';
+ return this.localeProvider.lang ? this.getLocales('cancelText') : '关闭';
},
okBtnText() {
- return this.okText || this.getLocales('okText') || '确定';
+ return this.localeProvider.lang ? this.getLocales('okText') : '确定';
},
},
watch: {
@@ -86,7 +86,7 @@ export default {
methods: {
// 国际化
getLocales(key) {
- return Locale.getLocaleByComponent(this, 'Confirm', key);
+ return Locale.getLocaleByComponent(this.localeProvider, 'Confirm', key);
},
},
};
diff --git a/src/locale-provider/src/locale-provider.vue b/src/locale-provider/src/locale-provider.vue
index 9a51a628..175da897 100644
--- a/src/locale-provider/src/locale-provider.vue
+++ b/src/locale-provider/src/locale-provider.vue
@@ -24,7 +24,7 @@ export default {
},
provide() {
return {
- localeProvider: this.locale[this.lang],
+ localeProvider: this,
};
},
};
diff --git a/src/search-bar/src/search-bar.vue b/src/search-bar/src/search-bar.vue
index a65e2c49..5154d1a1 100644
--- a/src/search-bar/src/search-bar.vue
+++ b/src/search-bar/src/search-bar.vue
@@ -11,17 +11,17 @@
- {{placeholderText}}
+ {{placeholder || placeholderText}}
-
{{cancelBtnText}}
+ }" ref="cancelRef" @click="onCancel">{{cancelText || cancelBtnText}}
@@ -80,7 +80,7 @@ export default {
};
},
watch: {
- 'value'(value, oldValue) { // eslint-disable-line no-unused-vars, object-shorthand
+ value(value) {
if (value === this.currentValue) return;
this.currentValue = value;
},
@@ -90,10 +90,10 @@ export default {
return this.currentValue ? 0 : 1;
},
cancelBtnText() {
- return this.cancelText || this.getLocales('cancelText') || '关闭';
+ return this.localeProvider.lang ? this.getLocales('cancelText') : '取消';
},
placeholderText() {
- return this.placeholder || this.getLocales('placeholder') || '搜索';
+ return this.localeProvider.lang ? this.getLocales('placeholder') : '搜索';
},
},
mounted() {
@@ -104,7 +104,7 @@ export default {
methods: {
// 国际化
getLocales(key) {
- return Locale.getLocaleByComponent(this, 'SearchBar', key);
+ return Locale.getLocaleByComponent(this.localeProvider, 'SearchBar', key);
},
// 初始化搜索提示文字的位置
calculatePositon() {
diff --git a/src/utils/locale.js b/src/utils/locale.js
index 2650aa93..472f0f59 100644
--- a/src/utils/locale.js
+++ b/src/utils/locale.js
@@ -1,9 +1,10 @@
export default {
- getLocaleByComponent($component, name = '', key) {
- if (!$component.localeProvider) return '';
- const componentProvider = $component.localeProvider[name];
- if (componentProvider) {
- return componentProvider[key];
+ getLocaleByComponent(localeProvider, name = '', key) {
+ if (!localeProvider) return '';
+ const currentLang = localeProvider.lang;
+ if (currentLang) {
+ const currentProvider = localeProvider.locale[currentLang];
+ return currentProvider[name][key];
}
return '';
},