Requirements: as soon as you enter the page, you have to send three requests. If the loading is not well written one by one; If the promise is not suitable,
finally, + +, – it is good to process it through computed
HTML
<div v-loading="loading" class="dashboard-container"></div>
Computed method
computed: {
loading() {
return this.loadingCount !== 0
}
},
Requests to be used in the lifecycle
mounted() {
this.yearAndQuarter = curYearAndQuarter()
// Requesting list data
this.getListData(this.yearAndQuarter)
// Request a map
this.getMapData(this.yearAndQuarter)
// Request project list details
this.getProlistDetails()
},
Used in requests
// Request project list details
getProlistDetails() {
this.loadingCount++
const params = {
'serviceId': 'data_market_screen_xmlb2_test',
}
queryByPage(params).then((res) => {
this.loadingCount--
console.log('Request item list details', res)
// this.lightspotList = res.data
}).catch(e => {
this.loadingCount--
this.$message.error(e.toString())
})
},
getMapData(yearAndQuarter) {
this.loadingCount++
const yOrR = yearAndQuarter.split('-')
const params = {
'serviceId': 'data_market_screen_map_test',
}
queryByPage(params).then((res) => {
this.loadingCount--
console.log('Map', res)
this.lightspotList = res.data
}).catch(e => {
this.loadingCount--
this.$message.error(e.toString())
})
},
Read More:
- [Solved] it only responds to error and does not enter success after AJAX is successfully processed
- Trigger http request when tab page is closed in angular2+ project
- “Failed to load resource: net::ERR_FILE_NOT_FOUND” error. The project created by vue-cli 3.0 can run under dev, and an error is reported after packaging, and the page is blank.
- [Solved] Vue Error: Uncaught TypeError: Vue.createApp is not a function
- Vue2.0: How to Use vue3 api to encapsulate Axios
- [Solved] Vue uses webpack to package error: Createapp is not a function
- [Solved] Vue route jumps to the same page many times error: Navigationduplicated
- Vue Error: error in mounted hook: TypeError: invalid src type
- How to Solve Vue loading 3D model Error
- How to open a page in a new window by Vue router
- [Solved] VUE Error: Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘$on‘)“
- [Solved] Vue Route Error: Uncaught TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_42__.defineComponent) is not a function
- Vue refreshes the current page (no flash screen will appear)
- Vue project change directory run error:Multiple assets emit different content to the same filename index.html
- [Solved] Vue3.2 component computed Error: Write operation failed: computed value is readonly
- [Solved] React Startup Error at the First time :SyntaxError: Unexpected token
- Ant design vue table Error: h is not defined [How to Solve]
- vue.config.js build Package UglifyJsPlugin to clear console and print console.log Error: `warnings` is not a supported option
- How to Solve “Vue is not defined” Error
- [Solved] Vue3 Error: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. P