Vue-touch的使用
有時(shí)候我們不止需要有返回鍵,也要有手勢(shì)滑動(dòng)切換頁(yè)面的功能時(shí),這個(gè)時(shí)候vue-touch就派上用場(chǎng)了
API地址:
https://github.com/vuejs/vue-touch/tree/next
安裝
npm insall vue-touch@next --save//main.js中引入:import VueTouch from 'vue-touch'Vue.use(VueTouch, {name: 'v-touch'})用法如下:
//html代碼<template> <v-touch v-on:swipeleft="swiperleft" v-on:swiperight="swiperright" class="wrapper">   <div class="menu-container" ref="menuContainer">    <!-- 這個(gè)是內(nèi)容 -->    </div> </v-touch></template>export default { name: 'Queue', data () {  return {  } }, methods: {  swiperleft: function () {   this.$router.push({'path':'/queuehistory'});  },  swiperright: function () {   this.$router.push({'path':'/home'});  } }}下面給大家介紹下vue2.0移動(dòng)端滑動(dòng)事件vue-touch,具體內(nèi)容如下所述:
https://github.com/vuejs/vue-touch/tree/next
cnpm install vue-touch@nextvar VueTouch = require('vue-touch')Vue.use(VueTouch, {name: 'v-touch'})//左劃   默認(rèn)渲染為div  data為參數(shù)<v-touch v-on:swipeleft="onSwipeLeft(data)">Swipe me!</v-touch>//點(diǎn)擊  渲染為一個(gè)a標(biāo)簽<v-touch tag="a" v-on:tap="onTap">Tap me!</v-touch>//點(diǎn)擊  渲染為p標(biāo)簽<v-touch tag="p" v-on:tap="onTap">Tap me!</v-touch>總結(jié)
以上所述是小編給大家介紹的vue2.0移動(dòng)端滑動(dòng)事件vue-touch的實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!
新聞熱點(diǎn)
疑難解答