Current location - Education and Training Encyclopedia - Resume - How does el-alert dynamically modify the title in VUE3 element-plus?
How does el-alert dynamically modify the title in VUE3 element-plus?
You need to request the back-end interface with Ajax, accept the return value, and then disassemble the return value object into the corresponding ele element. Ajax library recommended? Axios, download and install Axios using NPM (provided that Node.js is downloaded), then create a utils folder in src, create a request.js under it and write:

//Introducing axios Library

Import axios from "axios"; ?

const request =axios.create({

BaseURL:' main link address'//Example: www.xxx.com/xxx.api.xxx.xxx.xx.

})

Export the default request; //Export module

You can use it src = & gtapi => to write in xxx.js

Import request from @/utils/request; //Here is the request file just written.

export const get data =()= & gt; Request ({

Method:' GET' // Write request type

Url:' This is an auxiliary connection'//Example: www.xxx.com/xxx.api.xxx.xxx.xx.

})

Finally, link the file to the corresponding file of Vue 3.

Import {getData} from @/api/xxx.

//Initialization data method for encapsulating homepage

const initIndexData = async()= & gt; {

//Deconstruct the item [data in data]

const { data } = await getHomeData()

//Judge whether the data is obtained.

if(data.status! == 200) {

//If no data is obtained, return directly.

Return;

}

//Assign the collected data to indexData.

indexData.value = data.data

}

//Call the initialization data method of the home page.

initIndexData()

Finally, put the analysis data into the specified location.