Get the calling element with vue.js

后端 未结 3 857
隐瞒了意图╮
隐瞒了意图╮ 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:17

    You want v-el to be able to run jQuery on it. For example:

    Test

    then:

    // as noted by @vistajess
    // your function should be in the methods object
    // not the data object
    methods: {
        testFunction : function() {
            $(this.$els.myElement).doSomethingWithIt();
        }
    }
    

提交回复
热议问题