murilo
178
3
Vue

Set Data in VUE Dinamic

Posted 6 months 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.

Reply to

Use Markdown with GitHub-flavored code blocks.