index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <demo-section>
  3. <demo-block :title="$t('basicUsage')">
  4. <van-search
  5. v-model="value"
  6. :placeholder="$t('placeholder')"
  7. />
  8. </demo-block>
  9. <demo-block :title="$t('title2')">
  10. <form action="/">
  11. <van-search
  12. v-model="value"
  13. :placeholder="$t('placeholder')"
  14. show-action
  15. @search="onSearch"
  16. @cancel="onCancel"
  17. />
  18. </form>
  19. </demo-block>
  20. <demo-block :title="$t('title3')">
  21. <van-search
  22. v-model="value"
  23. :placeholder="$t('placeholder')"
  24. show-action
  25. shape="round"
  26. :label="$t('label')"
  27. @search="onSearch"
  28. >
  29. <div
  30. slot="action"
  31. @click="onSearch"
  32. >
  33. {{ $t('search') }}
  34. </div>
  35. </van-search>
  36. </demo-block>
  37. </demo-section>
  38. </template>
  39. <script>
  40. export default {
  41. i18n: {
  42. 'zh-CN': {
  43. title2: '监听对应事件',
  44. title3: '高级用法',
  45. placeholder: '请输入搜索关键词',
  46. label: '地址'
  47. },
  48. 'en-US': {
  49. title2: 'Listen to Events',
  50. title3: 'Advanced Usage',
  51. placeholder: 'Placeholder',
  52. label: 'Address'
  53. }
  54. },
  55. data() {
  56. return {
  57. value: ''
  58. };
  59. },
  60. methods: {
  61. onSearch() {
  62. this.$toast(this.value);
  63. },
  64. onCancel() {
  65. this.$toast(this.$t('cancel'));
  66. }
  67. }
  68. };
  69. </script>