Problems related to vue

Project scenario: there is a circular list of data given by the backend, in which there is a radio button indicating "default / set to default". When I click the radio button, I need to request from the backend to change the currently selected "default" and the corresponding text. Now what I do is to request the list interface again.

use framework: vue

question: apart from requesting the interface again, what VUE can be used to solve this problem?

Mar.06,2021

do you mean the text changes after clicking?

@click="change($event)"

change(e){
   e.target.innerText = ''
}

then upstairs (the following grammar format is not important, written casually to save time):

template:

<button @click="change($event)">{{ isDefault ? '' : ''}}</button>

data(){
    return {
        isDefault : true
    }
}

created:

var data = datatrue
this.isDefault= data.status;

methods:

change(e){
   
    // isDefaultok
    axios.post(url,params).then((res)=>{
        if(res.data == true) this.isDefault = !this.isDefault;
    })

}

you should have two interfaces in this
1. Get the interface of the list
2. The API
of an item in the change list starts by getting the list API to pull the list that needs to be displayed. When you change the status of an item, you should listen to the change event of this item and send a request for change to the backend. If successful, you can modify the content of the text at the front end. If it is not successful, do not modify it.


when you click a line of buttons in the list, send a request to set the default interface to the background. After the request is successful, change the text of the button (previous button and current button)

Menu