how to access refs in methods in vuejs
04:56 27 Feb 2019

I want to access template ref in functions inside method objects. Currently, it throws undefined when accessing the refs.

My Code Below:


And My Code in Script tag is below:

export default {
    methods: {
        getMileStonePercent(num, secWrp) {
            let ele = this.$refs[secWrp]
            return ele.offsetWidth + '%'
        },
    },
    created() {},
}

Kindly, provide solution to get the width by accessing the template reference in my function. Thanks in advance.

vue.js reference vuejs2 vue-component ref