打开src/router/index.js
1.先导入要进行链接地址的组件文件。例如:
import Graphfrom "../components/Graph";
1、 默认首页路由为 path: ‘/’,把想设置为首页的vue组件的路径设置为 ‘/’即可.
routes: [{
path:'/',
name:'Graph',
component: Graph
}]
2、添加一个mode:”history”,取消url后面的#号,这样打开网页的url后面就没有#号了
mode:"history"
3.修改端口。
打开config/index.js,修改其中的host,port即可
附上src/router/index.js 完整文件代码:
import Vuefrom 'vue'
import Routerfrom 'vue-router'
import pieGraphfrom "../components/pieGraph";
import Graphfrom "../components/Graph";
Vue.use(Router)
export default new Router({
routes: [
{
path:'/',
name:'Graph',
component: Graph
}
],
mode:"history"
})
网友评论