dongtingyue
V2EX  ›  Vue.js

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

  •  
  •   dongtingyue · Mar 24, 2023 · 2807 views
    This topic created in 1321 days ago, the information mentioned may be changed or developed.

    现在的方式

    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
    luckyx
    Mar 24, 2023
    1
    component = () => import('./children/test.vue')

    其实不太明白你问什么
    luckyx
    luckyx
    Mar 24, 2023
    2
    *typo above
    component: () => import('./children/test.vue')
    ramcasky
    ramcasky
    Mar 24, 2023
    3
    你想问的是 ssr 后端渲染吧?看看 next 或者 nuxt
    dongtingyue
    dongtingyue
    OP
    Mar 24, 2023
    4
    @luckyx 就是页面源码是存数据库,前端要如何通过接口获取到后加载路由对应的页面
    dongtingyue
    dongtingyue
    OP
    Mar 24, 2023
    5
    @ramcasky 不在后端渲染。只是页面是编辑后存数据库。
    w07128597
    w07128597
    Mar 24, 2023
    6
    你是想远程加载组件吧,才有人问过
    https://www.v2ex.com/t/926440
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2902 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:32 · PVG 20:32 · LAX 04:32 · JFK 07:32
    ♥ Do have faith in what you're doing.