Main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
路由配置
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
{
path:'/',
component:()=>import('../views/Index.vue')
},
{
path:'/channelManage',
component:()=>import('../views/ChannelManage.vue')
},
]
const router = new VueRouter({
routes
})
export default router
APP.vue
<template>
<div id="app">
<router-view/>
</div>
</template>
<script>
import axios from 'axios'
export default {
created() {
// 发送请求,获取频道信息
this.getNav()
},
methods: {
async getNav(){
let {data:{result}} = await axios.get('/json/nav.json')
this.$store.dispatch('muChannels',result)
}
},
}
</script>
<style lang="scss">
* {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
outl