index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <demo-section>
  3. <demo-block :title="$t('basicUsage')">
  4. <van-button @click="show1 = true">{{ $t('button1') }}</van-button>
  5. <van-actionsheet
  6. v-model="show1"
  7. :actions="actions"
  8. @select="onSelect"
  9. />
  10. </demo-block>
  11. <demo-block :title="$t('title2')">
  12. <van-button @click="show2 = true">{{ $t('button2') }}</van-button>
  13. <van-actionsheet
  14. v-model="show2"
  15. :actions="actions"
  16. :cancel-text="$t('cancel')"
  17. @cancel="onCancel"
  18. @select="onSelect"
  19. />
  20. </demo-block>
  21. <demo-block :title="$t('title3')">
  22. <van-button @click="show3 = true">{{ $t('button3') }}</van-button>
  23. <van-actionsheet
  24. v-model="show3"
  25. :title="$t('title')"
  26. >
  27. <p>{{ $t('content') }}</p>
  28. </van-actionsheet>
  29. </demo-block>
  30. </demo-section>
  31. </template>
  32. <script>
  33. export default {
  34. i18n: {
  35. 'zh-CN': {
  36. button1: '弹出 Actionsheet',
  37. button2: '弹出带取消按钮的 Actionsheet',
  38. button3: '弹出带标题的 Actionsheet',
  39. title2: '带取消按钮的 Actionsheet',
  40. title3: '带标题的 Actionsheet',
  41. description: '描述信息',
  42. disabledOption: '禁用选项'
  43. },
  44. 'en-US': {
  45. button1: 'Show Actionsheet',
  46. button2: 'Show Actionsheet with cancel button',
  47. button3: 'Show Actionsheet with title',
  48. title2: 'Actionsheet with cancel button',
  49. title3: 'Actionsheet with title',
  50. description: 'Description',
  51. disabledOption: 'Disabled Option'
  52. }
  53. },
  54. data() {
  55. return {
  56. show1: false,
  57. show2: false,
  58. show3: false
  59. };
  60. },
  61. computed: {
  62. actions() {
  63. return [
  64. { name: this.$t('option') },
  65. { name: this.$t('option'), subname: this.$t('description') },
  66. { loading: true },
  67. { name: this.$t('disabledOption'), disabled: true }
  68. ];
  69. }
  70. },
  71. methods: {
  72. onSelect(item) {
  73. this.show1 = false;
  74. this.show2 = false;
  75. this.$toast(item.name);
  76. },
  77. onCancel() {
  78. this.$toast('cancel');
  79. }
  80. }
  81. };
  82. </script>
  83. <style lang="less">
  84. .demo-actionsheet {
  85. .van-button {
  86. margin-left: 15px;
  87. }
  88. p {
  89. padding: 20px;
  90. }
  91. }
  92. </style>