Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

vue.js - 如何在VueJS中实现箭头功能?(How can I implement arrow function in VueJS?)

My method in vue looks like this :

(我在vue中的方法如下所示:)

methods: { 
    setDate: async function () {
        console.log(this.modal)
    }
}

I want to change it to an arrow function.

(我想将其更改为箭头功能。)

I tried like this :

(我这样尝试过:)

methods: { 
    setDate: async () => {
        console.log(this.modal)
    }
}

There exist error like this :

(存在这样的错误:)

Cannot read property 'modal' of undefined

How can I solve this problem?

(我怎么解决这个问题?)

  ask by positive thinking translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

use function directly like

(直接使用功能就像)

methods: { 
    async setDate() {
        console.log(this.modal)
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...