Volunteer.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <v-touch
  3. class="JoinVo"
  4. @swipeleft="moveSwiper(1)"
  5. @swiperight="moveSwiper(0)"
  6. >
  7. <div
  8. @click="skip(item.id)"
  9. class="row"
  10. :class="{ active: index === imgInd }"
  11. v-for="(item, index) in imgList"
  12. :key="index"
  13. >
  14. <!-- <p>{{ item.name }}</p> -->
  15. <img
  16. :src="require(`@/assets/img/Join/${item.id}.png`)" alt=""
  17. />
  18. </div>
  19. </v-touch>
  20. </template>
  21. <script>
  22. export default {
  23. name: "JoinVo",
  24. components: {},
  25. data() {
  26. //这里存放数据
  27. return {
  28. imgInd: 0,
  29. imgList: [
  30. { id: 1, name: "Volunteer Team Introduction" },
  31. { id: 2, name: "Volunteer Apply" },
  32. { id: 3, name: "Volunteer Program" },
  33. ],
  34. };
  35. },
  36. //监听属性 类似于data概念
  37. computed: {},
  38. //监控data中的数据变化
  39. watch: {},
  40. //方法集合
  41. methods: {
  42. skip(id) {
  43. this.$router.push({
  44. name: "JoinInfo",
  45. query: { id },
  46. });
  47. },
  48. moveSwiper(val) {
  49. if (val === 1) {
  50. // +
  51. if (this.imgInd === this.imgList.length - 1) this.imgInd = 0;
  52. else this.imgInd++;
  53. } else {
  54. // -
  55. if (this.imgInd === 0) this.imgInd = this.imgList.length - 1;
  56. else this.imgInd--;
  57. }
  58. },
  59. },
  60. //生命周期 - 创建完成(可以访问当前this实例)
  61. created() {},
  62. //生命周期 - 挂载完成(可以访问DOM元素)
  63. mounted() {},
  64. beforeCreate() {}, //生命周期 - 创建之前
  65. beforeMount() {}, //生命周期 - 挂载之前
  66. beforeUpdate() {}, //生命周期 - 更新之前
  67. updated() {}, //生命周期 - 更新之后
  68. beforeDestroy() {}, //生命周期 - 销毁之前
  69. destroyed() {}, //生命周期 - 销毁完成
  70. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  71. };
  72. </script>
  73. <style lang='less' scoped>
  74. .JoinVo {
  75. touch-action: pan-y!important;
  76. padding: 20px 0 40px;
  77. background-color: #f7f6f3;
  78. .row {
  79. transition: all 0.3s;
  80. position: relative;
  81. overflow: hidden;
  82. width: 100%;
  83. opacity: 0;
  84. height: 0;
  85. &>img{
  86. width: 100%;
  87. }
  88. }
  89. .active {
  90. opacity: 1;
  91. height: auto;
  92. }
  93. }
  94. </style>