Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter when we v-touch:swipe="myMethod(direction, myOtherParam)" #3

Closed
Nordes opened this issue Aug 19, 2017 · 4 comments
Closed

Comments

@Nordes
Copy link

Nordes commented Aug 19, 2017

Hi,

As the title says, it would be nice to have something like a binding with extra parameters.

Example
v-touch:swipe="myMethod(direction, myOtherParam)"

@jerrybendy
Copy link
Owner

I'm sorry to reply you too late, I'm too busy these days.

If you have some good solution to handle this issue, you can give me a PR, and I'll merge it soon. 😊

@Nordes
Copy link
Author

Nordes commented Aug 28, 2017

I'll check what I can do. I have quite a good load of work also on my side.

@jerrybendy
Copy link
Owner

I think it is difficult to implement this feature. v-touch is a custom directive, not similar to v-on.

If you put myMethod(direction, myOtherParam) as parameter, actually the parameter send to v-touch is the result of this expression. And it's meaningless for v-touch.

@jerrybendy
Copy link
Owner

If you really want to do this, maybe you can write like that:

<div v-touch:swipe="myMethod(myOtherParam)">Swipe</div>
export default {
  methods: {
    myMethod (param) {
      return function(dir) {
        console.log(dir, param);
      }
    }
  }
}

Just return a function and append your own parameters is okay :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants