From fd385bce9d7fff087ea949d9cf94da201391ac34 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 2 Jan 2021 12:59:55 +0800 Subject: [PATCH] docs(NumberKeyboard): add random key order demo (#7844) --- src/number-keyboard/README.md | 34 ++++--------------- src/number-keyboard/README.zh-CN.md | 32 ++++------------- src/number-keyboard/demo/index.vue | 20 +++++++++-- src/number-keyboard/index.js | 5 +-- .../test/__snapshots__/demo.spec.js.snap | 7 ++++ 5 files changed, 39 insertions(+), 59 deletions(-) diff --git a/src/number-keyboard/README.md b/src/number-keyboard/README.md index dff8e8adf..a9381d5bd 100644 --- a/src/number-keyboard/README.md +++ b/src/number-keyboard/README.md @@ -111,43 +111,23 @@ Use `title` prop to set keyboard title. /> ``` -### Number Random +### Random Key Order -Use `random-key-order` prop to random sort number keypads. +Use `random-key-order` prop to shuffle the order of keys. ```html -弹出配置随机数字的键盘 + + Show Keyboard With Random Key Order + ``` -```js -import { Toast } from 'vant'; - -export default { - data() { - return { - show: true, - }; - }, - methods: { - onInput(value) { - Toast(value); - }, - onDelete() { - Toast('删除'); - }, - }, -}; -``` - ### Bind Value ```html @@ -197,7 +177,7 @@ export default { | hide-on-click-outside | Whether to hide keyboard when outside is clicked | _boolean_ | `true` | | get-container `v2.10.0` | Return the mount node for NumberKeyboard | _string \| () => Element_ | - | | safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` | -| random-key-order | whether to enable random sort number keypads | _boolean_ | `false` | +| random-key-order `v2.12.2` | Whether to shuffle the order of keys | _boolean_ | `false` | ### Events diff --git a/src/number-keyboard/README.zh-CN.md b/src/number-keyboard/README.zh-CN.md index e5215fbe2..2f7b22bad 100644 --- a/src/number-keyboard/README.zh-CN.md +++ b/src/number-keyboard/README.zh-CN.md @@ -124,41 +124,21 @@ export default { ### 随机数字键盘 -通过 `random-key-order` 属性可以随机排序数字键盘,常用于安全等级较高的场景 +通过 `random-key-order` 属性可以随机排序数字键盘,常用于安全等级较高的场景。 ```html -弹出配置随机数字的键盘 + + 弹出配置随机数字的键盘 + ``` -```js -import { Toast } from 'vant'; - -export default { - data() { - return { - show: true, - }; - }, - methods: { - onInput(value) { - Toast(value); - }, - onDelete() { - Toast('删除'); - }, - }, -}; -``` - ### 双向绑定 可以通过 `v-model` 绑定键盘当前输入值。 @@ -210,7 +190,7 @@ export default { | hide-on-click-outside | 点击外部时是否收起键盘 | _boolean_ | `true` | | get-container `v2.10.0` | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| () => Element_ | - | | safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/advanced-usage#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` | -| random-key-order | 是否随机键盘数字 | _boolean_ | `false` | +| random-key-order `v2.12.2` | 是否将通过随机顺序展示按键 | _boolean_ | `false` | ### Events diff --git a/src/number-keyboard/demo/index.vue b/src/number-keyboard/demo/index.vue index 32fb81afc..256ccb9f7 100644 --- a/src/number-keyboard/demo/index.vue +++ b/src/number-keyboard/demo/index.vue @@ -15,6 +15,9 @@ {{ t('button5') }} + + {{ t('button6') }} + + + - @@ -93,10 +104,12 @@ export default { button3: '弹出身份证号键盘', button4: '弹出带标题的键盘', button5: '弹出配置多个按键的键盘', + button6: '弹出配置随机数字的键盘', + extraKey: '左下角按键内容', bindValue: '双向绑定', clickToInput: '点此输入', - extraKey: '左下角按键内容', multiExtraKey: '配置多个按键', + randomKeyOrder: '随机数字键盘', }, 'en-US': { close: 'Close', @@ -107,10 +120,12 @@ export default { button3: 'Show IdNumber Keyboard', button4: 'Show Keyboard With Title', button5: 'Show Keyboard With Multiple ExtraKey', + button6: 'Show Keyboard With Random Key Order', bindValue: 'Bind Value', clickToInput: 'Click To Input', extraKey: 'IdNumber Keyboard', multiExtraKey: 'Multiple ExtraKey', + randomKeyOrder: 'Random Key Order', }, }, @@ -118,6 +133,7 @@ export default { return { value: '', keyboard: 'default', + isTest: process.env.NODE_ENV === 'test', }; }, diff --git a/src/number-keyboard/index.js b/src/number-keyboard/index.js index 46c730b03..949b04aba 100644 --- a/src/number-keyboard/index.js +++ b/src/number-keyboard/index.js @@ -24,6 +24,7 @@ export default createComponent({ show: Boolean, title: String, zIndex: [Number, String], + randomKeyOrder: Boolean, closeButtonText: String, deleteButtonText: String, closeButtonLoading: Boolean, @@ -59,10 +60,6 @@ export default createComponent({ type: Boolean, default: true, }, - randomKeyOrder: { - type: Boolean, - default: false, - }, }, watch: { diff --git a/src/number-keyboard/test/__snapshots__/demo.spec.js.snap b/src/number-keyboard/test/__snapshots__/demo.spec.js.snap index 8de8b1efe..754986126 100644 --- a/src/number-keyboard/test/__snapshots__/demo.spec.js.snap +++ b/src/number-keyboard/test/__snapshots__/demo.spec.js.snap @@ -32,6 +32,12 @@ exports[`renders demo correctly 1`] = ` +
+
+ 弹出配置随机数字的键盘 +
+ +
双向绑定
@@ -277,6 +283,7 @@ exports[`renders demo correctly 1`] = `
+