CarouselWarp.vue 1.73 KB
Newer Older
hucy's avatar
hucy committed
1
<!--
hucy's avatar
hucy committed
2
 * 动态echar轮播图
hucy's avatar
hucy committed
3 4 5 6
  -->
<script setup lang="ts">
import { reactive, onMounted, onBeforeUnmount } from 'vue';
import Com from 'src/components';
7
import { WarpTestData, WarpTestData2, WarpTestData3 } from '../config';
hucy's avatar
hucy committed
8 9 10 11 12 13 14

const state = reactive({
  list: [] as any,
  times: 5000,
});

onMounted(() => {
15
  initData();
hucy's avatar
hucy committed
16 17 18 19 20 21 22 23 24 25
});

onBeforeUnmount(() => {
  //
});

function initData() {
  state.list = WarpTestData;
}

26 27 28 29
function onDataChange1() {
  state.list = WarpTestData;
}

hucy's avatar
hucy committed
30 31 32 33
function onDataChange2() {
  state.list = WarpTestData2;
}

34 35 36 37
function onDataChange3() {
  state.list = WarpTestData3;
}

hucy's avatar
hucy committed
38 39 40 41 42
function onSetToEnpty() {
  state.list = [];
}

function onChangeTimers() {
43 44
  state.times = 2000;
}
hucy's avatar
hucy committed
45 46 47 48
</script>
<template>
  <div class="fit">
    <div class="my-warp-box">
hucy's avatar
hucy committed
49
      <Com.ChartCarouselWarp
hucy's avatar
hucy committed
50
        navigation
hucy's avatar
hucy committed
51
        item-key="seq"
hucy's avatar
hucy committed
52 53 54
        :list="state.list"
        :times="state.times"
      >
hucy's avatar
hucy committed
55
      </Com.ChartCarouselWarp>
hucy's avatar
hucy committed
56 57
    </div>
    <div class="btns">
58 59 60 61 62
      <q-btn
        label="图表轮播图测试数据1"
        @click="onDataChange1"
        color="primary"
      />
hucy's avatar
hucy committed
63 64 65 66 67
      <q-btn
        label="图表轮播图测试数据2"
        @click="onDataChange2"
        color="primary"
      />
68 69 70 71 72
      <q-btn
        label="图表轮播图测试数据3"
        @click="onDataChange3"
        color="primary"
      />
hucy's avatar
hucy committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
      <q-btn label="将数据置为空" @click="onSetToEnpty" color="primary" />
      <q-btn label="改变轮播时间" @click="onChangeTimers" color="orange" />
    </div>
  </div>
</template>

<style lang="scss" scoped>
.my-warp-box {
  width: 500px;
  height: 300px;
}
.btns {
  padding-top: $padding-md;
  display: flex;
  flex-wrap: wrap;
  > button {
    margin-right: $padding-sm;
    margin-bottom: $padding-md;
  }
}
</style>