index.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <demo-section>
  3. <demo-block :title="$t('default')">
  4. <van-button @touchstart.stop="keyboard = 'default'">
  5. {{ $t('button1') }}
  6. </van-button>
  7. <van-number-keyboard
  8. :show="keyboard === 'default'"
  9. :close-button-text="$t('close')"
  10. extra-key="."
  11. @blur="keyboard = ''"
  12. @input="onInput"
  13. @delete="onDelete"
  14. />
  15. </demo-block>
  16. <demo-block :title="$t('custom')">
  17. <van-button @touchstart.stop="keyboard = 'custom'">
  18. {{ $t('button2') }}
  19. </van-button>
  20. <van-number-keyboard
  21. :show="keyboard === 'custom'"
  22. :close-button-text="$t('close')"
  23. theme="custom"
  24. extra-key="."
  25. @blur="keyboard = ''"
  26. @input="onInput"
  27. @delete="onDelete"
  28. />
  29. </demo-block>
  30. </demo-section>
  31. </template>
  32. <script>
  33. export default {
  34. i18n: {
  35. 'zh-CN': {
  36. default: '默认样式',
  37. custom: '自定义样式',
  38. button1: '弹出默认键盘',
  39. button2: '弹出自定义键盘',
  40. close: '完成'
  41. },
  42. 'en-US': {
  43. default: 'Default style',
  44. custom: 'Custom style',
  45. button1: 'Show Default Keyboard',
  46. button2: 'Show Custom Keyboard',
  47. close: 'Close'
  48. }
  49. },
  50. data() {
  51. return {
  52. keyboard: 'default'
  53. };
  54. },
  55. methods: {
  56. onInput(value) {
  57. this.$toast('Input: ' + value);
  58. },
  59. onDelete() {
  60. this.$toast('Delete');
  61. }
  62. }
  63. };
  64. </script>
  65. <style lang="less">
  66. .demo-number-keyboard {
  67. .van-button {
  68. margin-left: 15px;
  69. }
  70. }
  71. </style>