index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div>
  3. <demo-section>
  4. <van-notice-bar>{{ $t('tips') }}</van-notice-bar>
  5. <demo-block :title="$t('basicUsage')">
  6. <van-swipe-cell
  7. :right-width="65"
  8. :left-width="65"
  9. >
  10. <span slot="left">{{ $t('button1') }}</span>
  11. <van-cell-group>
  12. <van-cell
  13. :title="$t('title')"
  14. :value="$t('content')"
  15. />
  16. </van-cell-group>
  17. <span slot="right">{{ $t('button2') }}</span>
  18. </van-swipe-cell>
  19. </demo-block>
  20. <demo-block :title="$t('title2')">
  21. <van-swipe-cell
  22. :right-width="65"
  23. :left-width="65"
  24. :on-close="onClose"
  25. >
  26. <span slot="left">{{ $t('button1') }}</span>
  27. <van-cell-group>
  28. <van-cell
  29. :title="$t('title')"
  30. :value="$t('content')"
  31. />
  32. </van-cell-group>
  33. <span slot="right">{{ $t('button2') }}</span>
  34. </van-swipe-cell>
  35. </demo-block>
  36. </demo-section>
  37. </div>
  38. </template>
  39. <script>
  40. export default {
  41. i18n: {
  42. 'zh-CN': {
  43. button1: '选择',
  44. button2: '删除',
  45. title: '单元格',
  46. title2: '异步关闭',
  47. confirm: '确定删除吗?',
  48. tips: '建议在手机模式下浏览本示例'
  49. },
  50. 'en-US': {
  51. button1: 'Select',
  52. button2: 'Delete',
  53. title: 'Cell',
  54. title2: 'Async close',
  55. confirm: 'Are you sure to delete?',
  56. tips: 'Please try this demo in mobile mode'
  57. }
  58. },
  59. methods: {
  60. onClose(clickPosition, instance) {
  61. switch (clickPosition) {
  62. case 'left':
  63. case 'cell':
  64. case 'outside':
  65. instance.close();
  66. break;
  67. case 'right':
  68. this.$dialog.confirm({
  69. message: this.$t('confirm')
  70. }).then(() => {
  71. instance.close();
  72. });
  73. break;
  74. }
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="less">
  80. @import '../../style/var';
  81. .demo-swipe-cell {
  82. user-select: none;
  83. .van-swipe-cell {
  84. &__left,
  85. &__right {
  86. color: @white;
  87. font-size: 15px;
  88. width: 65px;
  89. height: 44px;
  90. display: inline-block;
  91. text-align: center;
  92. line-height: 44px;
  93. background-color: @red;
  94. }
  95. }
  96. }
  97. </style>