Vue loads the template with variables. No, you can write it yourself.

as shown in the figure, variable, no

     datas.forEach(item => {
                let newRoute = {
                  path: item.path,
                  name: item.name,
                  meta: {
                    title: item.title,
                    hideInMenu: false
                  },
                  component: (resolve) => require(["@" + item.componentPath], resolve)
                }
                // newRoute.component = () => import(`@/${item.componentPath}`)
                // console.info("path ", () => import(`@/${item.componentPath}`))
                if (item.children.length > 0) {
                  newRoute.children = makeRouter(item.children, newRoute)
                }

                store.push(newRoute)
              })

clipboard.png

:


clipboard.png

clipboard.png

Jul.12,2021

it is not possible to add variables directly to require .

if you are built by webpack, try require.context

The

stamp is detailed here: ides/dependency-management.html-sharprequirecontext" rel=" nofollow noreferrer "> require.context

your project directory file structure is not familiar here, so I'll give you a direction. You can refer to section 7 of this article

. The path of

variable splicing is not the same as the path you wrote to death. Should I tell you quietly ~

?
Menu