import router from "./router" 中路由器的定义在哪里
where is the definition of router in import router from "./router"
参考:Bulma
https://github.com/troymott/bulma-book-code/blob/master/vuejs/src/main.js
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
new Vue({
el: "#app",
router,
render: h => h(App),
});
https://github.com/troymott/bulma-book-code/blob/master/vuejs/src/router/index.js
import Vue from "vue";
import Router from "vue-router";
...
import CustomerEdit from "../pages/CustomerEdit.vue";
Vue.use(Router);
export default new Router({
routes: [{
path: "/",
redirect: '/login'
},
...
],
linkActiveClass: 'is-active' /* change to Bulmas active nav link */
});
问题> 我无法找到代码定义路由器变量的位置。有人可以帮我指出 router
的变量是在 router/index.js
中定义的吗?
谢谢
它不是变量或函数,而是从 router/index.js
传递的实例
export default new Router({
routes: [{
path: "/",
redirect: '/login'
},
...
],
linkActiveClass: 'is-active' /* change to Bulmas active nav link */
});
实际上被 main.js 中的变量 router
引用,然后在创建 vue
实例时使用。
new Vue({
el: "#app",
router, // place of usage
render: h => h(App),
});
参考:Bulma
https://github.com/troymott/bulma-book-code/blob/master/vuejs/src/main.js
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
new Vue({
el: "#app",
router,
render: h => h(App),
});
https://github.com/troymott/bulma-book-code/blob/master/vuejs/src/router/index.js
import Vue from "vue";
import Router from "vue-router";
...
import CustomerEdit from "../pages/CustomerEdit.vue";
Vue.use(Router);
export default new Router({
routes: [{
path: "/",
redirect: '/login'
},
...
],
linkActiveClass: 'is-active' /* change to Bulmas active nav link */
});
问题> 我无法找到代码定义路由器变量的位置。有人可以帮我指出 router
的变量是在 router/index.js
中定义的吗?
谢谢
它不是变量或函数,而是从 router/index.js
export default new Router({
routes: [{
path: "/",
redirect: '/login'
},
...
],
linkActiveClass: 'is-active' /* change to Bulmas active nav link */
});
实际上被 main.js 中的变量 router
引用,然后在创建 vue
实例时使用。
new Vue({
el: "#app",
router, // place of usage
render: h => h(App),
});