V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
dongtingyue
V2EX  ›  Vue.js

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

  •  
  •   dongtingyue · 2023-03-24 14:17:47 +08:00 · 1190 次点击
    这是一个创建于 396 天前的主题,其中的信息可能已经有所发展或是发生改变。

    现在的方式

    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 的方式

    luckyx
        1
    luckyx  
       2023-03-24 14:59:29 +08:00
    component = () => import('./children/test.vue')

    其实不太明白你问什么
    luckyx
        2
    luckyx  
       2023-03-24 15:00:17 +08:00
    *typo above
    component: () => import('./children/test.vue')
    ramcasky
        3
    ramcasky  
       2023-03-24 15:54:38 +08:00
    你想问的是 ssr 后端渲染吧?看看 next 或者 nuxt
    dongtingyue
        4
    dongtingyue  
    OP
       2023-03-24 17:38:58 +08:00
    @luckyx 就是页面源码是存数据库,前端要如何通过接口获取到后加载路由对应的页面
    dongtingyue
        5
    dongtingyue  
    OP
       2023-03-24 17:40:03 +08:00
    @ramcasky 不在后端渲染。只是页面是编辑后存数据库。
    w07128597
        6
    w07128597  
       2023-03-24 20:17:39 +08:00
    你是想远程加载组件吧,才有人问过
    https://www.v2ex.com/t/926440
    yuekcc
        7
    yuekcc  
       2023-03-24 22:32:20 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3295 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 13:33 · PVG 21:33 · LAX 06:33 · JFK 09:33
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.