V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
dongtingyue
V2EX  ›  Vue.js

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

  •  
  •   dongtingyue · Mar 24, 2023 · 2274 views
    This topic created in 1133 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
        1
    luckyx  
       Mar 24, 2023
    component = () => import('./children/test.vue')

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