murilo
7
3
Vue

Set Data in VUE Dinamic

Posted 1 month ago by murilo

Hello I have a quention , I have a code , That sets diffent datas . is like this ->

if(data.type == "message"){
    this.message = data.result; 
}

if(data.type == "info"){
    this.info = data.result; 
}

if(data.type == "post"){
    this.post = data.result; 
}

How could I make this code dinamic, something like this -

    this[data.type] = data.result; 



Thanks

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.