vue main.js 配置 路由


// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './App';
import goods from './components/goods/goods';
import ratings from './components/ratings/ratings';
import seller from './components/seller/seller';

/* 安裝vue-router插件 */
Vue.use(VueRouter); // 注冊路由

/* 定義路由頁面 */
const routes = [
    // 這里 path: '/' 代表應用首頁顯示的內容
    { path: '/goods', component: goods },
    { path: '/ratings', component: ratings },
    { path: '/seller', component: seller }
];

const router = new VueRouter({
    // mode指定路由模式,默認'hash',另一種可選的模式是'history'
    mode: 'history',
    routes
});

/* 創建掛載點至#app元素,將內容顯示在index.html頁面 */
let app = new Vue({
    el: '#app',
    router,
    render: h => h(App)
});

Vue.use({
    app
});

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM