Get the calling element with vue.js

后端 未结 3 872
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 12:54

I want to get the calling html element in vue.js to modify it via jQuery. For now I give every element the class name + the index and call it via jQuery afterwards, but this loo

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-13 13:28

    You could get the element from the event like this:

    new Vue({
        el: "#app",
        methods: {  
            testFunction : function(event) {
                $(event.target).doSomethingWithIt();
            }
        }
    });
    

    And then:

    Test

    Or (if you want to pass another parameter):

    Test

    [demo]

提交回复
热议问题