vue 中vue-touch的使用

  • Post author:
  • Post category:vue


1、安装

npm install vue-touch@next –save

2、引入

在main.js中

import VueTouch from ‘vue-touch’

Vue.use(VueTouch, {name: ‘v-touch’})  v-touch可以是自定义名称

3、使用:

Vue.use注册的name名称,默认该标签为div

使用案例:

<v-touch @swipeleft="swipeleft_two" @swiperight="swiperight_two">
        <ul class="list">
          <li v-for="item in lists_raoul" :key="item.id" class="screen">
            <img :src="item.cover" alt="" />
            <h3>{{ item.title }}</h3>
            <p>评分:{{ item.rate }}</p>
          </li>
        </ul>
</v-touch>
methods: {
    swipeleft() {
      this.move = true;
      let now = document.getElementsByClassName("list")[0];
      now.style.transform += "translateX(-200px)";
      now.style.transition = "all linear 1s";
    },
    swiperight() {
      this.move = true;
      let now = document.getElementsByClassName("list")[0];
      if ((now.style.transform = "translateX(-200px)")) {
        now.style.transform += "translateX(200px)";
      }
      now.style.transition = "all linear 1s";
    },
}



版权声明:本文为m0_65544665原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。