How to use VUE to dynamically load asynchronous components?

The

requirement is to first get a list of component names asynchronously, then load the components on the list according to the list (in the form of a string array), and then cycle through the page

I made one according to the vue official website. Now I can load the components asynchronously, but I don"t know how to proceed.

<template>
  <div id="Menu">
    <component :is="Link"></component>
  </div>
</template>

<script>
const AsyncComponent = () => ({
  component: import(`../plugs/Link`)
})
export default {
  name: "Menu",
  components: {

  },
  data () {
    return {
      plugs: []
    }
  },
  created () {

  },
  computed: {
    Link: function () {
      return AsyncComponent
    }
  }
}
</script>
< hr >

answer from vv13:
the above example is what I am writing now, and it is easy to mislead people. I will change the example of requirements
the Link1, Link2 and other components in the examples in the current requirements do not necessarily exist, they are all a list of components obtained from another interface, for example:

<template>
  <div id="Menu">
    <!--  -->
  </div>
</template>

<script>
export default {
  name: "Menu",
  components: {
    // components
  },
  data () {
    plugs: [] // 
  },
  created () {
    // 
    fetch("plugs.php").then((data) => data.json()).then((data) => {
        // data ["Link1","Link2","components1","components2",...] components `../plugs/Link` 
        this.plugs = data;
    })
  },
  computed: {

  }
}
</script>
Nov.05,2021

There are two kinds of asynchronous component practices of

Vue. The first is ide/advanced/lazy-loading.html-sharp%E6%8A%8A%E7%BB%84%E4%BB%B6%E6%8C%89%E7%BB%84%E5%88%86%E5%9D%97" rel=" nofollow noreferrer "> routing lazy loading dividing the application into multiple chunk, from the routing layer to reduce the packaging volume of a single entry.

another way is that asynchronous components can be used to load Tab pages, pop-up windows and other things that do not need to be displayed immediately. Take your demo for example:

<template>
  <div id="Menu">
    <component :is="currentLink"></component>
  </div>
</template>

<script>
export default {
  name: 'Menu',
  components: {
    Link1: () => import(`../plugs/Link1`),
    Link2: () => import(`../plugs/Link2`),
  },
  data () {
    return {
      plugs: [],
      currentLink: 'Link1'
    }
  },
}
</script>

first load two dynamic components, Link1 and Link2, specify the name of the dynamic component through the currentLink in data, so that the component can be loaded dynamically.


has been resolved:

<template>
  <div id="menu">
    <component :is="plugItem"
               v-for="(plugItem, plugIndex) in plugs"
               :key='plugIndex'></component>
  </div>
</template>

<script>
export default {
  name: 'menu',
  data () {
    return {
      plugs: [
      ]
    }
  },
  created () {
    fetch('../assets/plugs.json').then((data) => data.text()).then((data) => {
      data.plugs.forEach(item => {
        this.plugs.push(() => import(`@/plugs/${item}`))
      })
    })
  }
}
</script>

I would like to ask the downstairs master, @ / plugs/ directory is the internal directory of the VUE project. Can you specifically display the component storage directory uploaded from the background

?
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eadc43-46c01.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eadc43-46c01.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?