Asynchronously request data, according to the request data require component

I am working on a page customization function. The template is stored in the background database, so you need to pull the template id, from the background and then follow the template id require corresponding to the components in the directory. For example,

require"/template"+tempid+"index.vue"

tempid is not known until it is requested.
I have found a lot of similar cases on the Internet, and some of them say to use

.
component: resolve => require(["component"], promise => promise.then(resolve))

component returns a promise, where then callback returns the final component

I am a beginner in vue, and I look confused and ask for advice


use vue-router beforeRouteEnter


Asynchronous problems can be solved by using beforeRouteEnter
beforeRouteEnter (to, from, next) {

request.get(url, {})
  .then(function (res) {
    info = res
    next()
  })
  .catch(function (error) {
    console.log(error)
  })

},

Menu