index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <demo-section>
  3. <demo-block :title="$t('ellipsis')">
  4. <div class="van-ellipsis">{{ $t('text') }}</div>
  5. </demo-block>
  6. <demo-block :title="$t('hairline')">
  7. <div class="van-hairline--top" />
  8. </demo-block>
  9. <demo-block :title="$t('animation')">
  10. <van-cell
  11. is-link
  12. title="Fade"
  13. @click="animate('van-fade')"
  14. />
  15. <van-cell
  16. is-link
  17. title="Slide Up"
  18. @click="animate('van-slide-up')"
  19. />
  20. <van-cell
  21. is-link
  22. title="Slide Down"
  23. @click="animate('van-slide-down')"
  24. />
  25. <van-cell
  26. is-link
  27. title="Slide Left"
  28. @click="animate('van-slide-left')"
  29. />
  30. <van-cell
  31. is-link
  32. title="Slide Right"
  33. @click="animate('van-slide-right')"
  34. />
  35. </demo-block>
  36. <transition :name="transitionName">
  37. <div
  38. v-show="show"
  39. class="demo-animate-block"
  40. />
  41. </transition>
  42. </demo-section>
  43. </template>
  44. <script>
  45. export default {
  46. i18n: {
  47. 'zh-CN': {
  48. hairline: '1px 边框',
  49. ellipsis: '文字省略',
  50. animation: '动画',
  51. toggle: '切换动画',
  52. text: '这是一段宽度限制 250px 的文字,后面的内容会省略'
  53. },
  54. 'en-US': {
  55. hairline: 'Hairline',
  56. ellipsis: 'Text Ellipsis',
  57. animation: 'Animation',
  58. toggle: 'Switch animation',
  59. text: 'This is a paragraph of 250px width limit, the back will be omitted.'
  60. }
  61. },
  62. data() {
  63. return {
  64. show: false,
  65. transitionName: ''
  66. };
  67. },
  68. methods: {
  69. animate(transitionName) {
  70. this.show = true;
  71. this.transitionName = transitionName;
  72. setTimeout(() => {
  73. this.show = false;
  74. }, 500);
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="less">
  80. @import '../../style/var';
  81. .demo-style {
  82. .van-ellipsis {
  83. font-size: 13px;
  84. margin-left: 15px;
  85. max-width: 250px;
  86. }
  87. .van-hairline--top {
  88. height: 30px;
  89. background-color: @white;
  90. &::after {
  91. top: 5px;
  92. }
  93. }
  94. .demo-animate-block {
  95. top: 50%;
  96. left: 50%;
  97. width: 100px;
  98. height: 100px;
  99. position: fixed;
  100. border-radius: 3px;
  101. margin: -50px 0 0 -50px;
  102. background-color: @blue;
  103. }
  104. }
  105. </style>