如何将 vue 页面改为动态引入

2023-03-24 14:17:47 +08:00
 dongtingyue

现在的方式

import Test from './children/test.vue'
....
{
                    path: '',
                    name: 'emptyView123123123123',
                    component: C2,
                    children: [
                        {
                            path: '',
                            name: 'test',
                            component: Test
                        }
                    ]
                }

想要实现的方式

//http 请求后端获取数据
pagesource = getpagesouce('test')
...
children: [
    {
        path: '',
        name: 'test',
        component: Test
        }
]

或者使用 pagesource new vue 的方式

1200 次点击
所在节点    Vue.js
7 条回复
luckyx
2023-03-24 14:59:29 +08:00
component = () => import('./children/test.vue')

其实不太明白你问什么
luckyx
2023-03-24 15:00:17 +08:00
*typo above
component: () => import('./children/test.vue')
ramcasky
2023-03-24 15:54:38 +08:00
你想问的是 ssr 后端渲染吧?看看 next 或者 nuxt
dongtingyue
2023-03-24 17:38:58 +08:00
@luckyx 就是页面源码是存数据库,前端要如何通过接口获取到后加载路由对应的页面
dongtingyue
2023-03-24 17:40:03 +08:00
@ramcasky 不在后端渲染。只是页面是编辑后存数据库。
w07128597
2023-03-24 20:17:39 +08:00
你是想远程加载组件吧,才有人问过
https://www.v2ex.com/t/926440
yuekcc
2023-03-24 22:32:20 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/926838

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX