// 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 });
