vue-cli4.5.11 实现多入口路由功能实现

2021-02-04 16:08:31 +08:00
 phpxiaowangzi

vue.config.js:

module.exports = {
    pages:{
        supplier:{
            entry:'src/supplier/main.js',
            template:'public/supplier.html',
            filename:'supplier.html',
            title:'合作伙伴'
        },
        staff:{
            entry:'src/staff/main.js',
            template:'public/staff.html',
            filename:'staff.html',
            title:'员工助手'
        }
    }
}

main.js:

import { createApp } from 'vue'
import VueRouter from 'vue-router'
import Supplier from './Supplier.vue'

import MicroPay from './components/MicroPay/index.vue'

const routes = [
    {path:'/MicroPay', component:MicroPay}
]

const router = new VueRouter({
	mode:'hash',
	routes
})

createApp(Supplier).use(router).mount('#supplier')

Supplier.vue:

<template>
    <div id="supplier">
        <router-view></router-view>
    </div>
</template>

<script>
    export default {
        name: 'Supplier'
    }
</script>

components/MicroPay/index.vue:

<template>
    <div>MicroPay</div>
</template>

<script>
    export default {
        name:'MicroPay'
    }
</script>

现在访问 http://localhost:8080/supplier#/MicroPay 空白无法显示 components/MicroPay/index.vue 文件内容,求教是否路由设置不正确,求前端大神指教。

1075 次点击
所在节点    程序员
1 条回复
PinkRabbit
2021-02-05 11:45:16 +08:00
空白的时候,看下控制台有没有报什么错误呢

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

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

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

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

© 2021 V2EX