【问题标题】:How to implement touch prop in Window component in vuetify?如何在 vuetify 的 Window 组件中实现 touch prop?
【发布时间】:2019-12-01 14:32:10
【问题描述】:

https://vuetifyjs.com/en/components/windows#windows

<v-window
   v-model="window"
   :touch = "swipe"        
>

如何在左右滑动时提供自定义左右功能?我这样做的方式不起作用,因为我无法访问我需要的变量,也无法在方法中调用函数。

export default {
  name :'test',
  data() {
    return {
      window: 0,
      length1:20,
      swipe: {
        length2:11,
        left: function() {
            //access both length1 and length2 here//
        },
        right:  function() {

        },
     }
    };

【问题讨论】:

    标签: vue.js vuetify.js


    【解决方案1】:

    您可以使用 :touch 直接从 v-window 调用函数,而不是使用数据。
    对我有用。

    <v-window
       v-model="window"
       :touch="{left: onSwipeLeft, right: onSwipeRight}"        
    >
    
    methods: {
      onSwipeLeft() {
       //do something with this.length1  or this.length2
      },
      onSwipeRight() {
       //exc
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-21
      • 1970-01-01
      • 2020-04-17
      • 2020-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多