這篇文章主要講解了“Vue如何實(shí)現(xiàn)登陸跳轉(zhuǎn)”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Vue如何實(shí)現(xiàn)登陸跳轉(zhuǎn)”吧!
白塔網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),白塔網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為白塔上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請找那個(gè)售后服務(wù)好的白塔做網(wǎng)站的公司定做!
效果圖
具體的實(shí)現(xiàn)方法,參照以下步驟~
1.創(chuàng)建login.vue,繪制login畫面,添加跳轉(zhuǎn)事件。
登錄平臺
登錄 記住密碼 忘記密碼
2.創(chuàng)建Home.vue菜單欄頁面
{{sysName}} {{sysUserName}} 我的消息 設(shè)置 退出登錄 {{$route.name}}
3.制作子頁面
homepage
4.路由配置
import Login from "./views/Login.vue" import Home from "./views/Home.vue" import Homepage from "./views/list/homepage.vue" import Table from "./views/list/Table.vue" let routes = [ { path: "/login", component: Login, name: "", hidden: true }, { path: "/", component: Home, name: "", leaf: true,//只有一個(gè)節(jié)點(diǎn) iconCls: "el-icon-menu", //圖標(biāo)樣式class children: [ { path: "/homepage", component: Homepage, name: "首頁" }, ] }, { path: "/", component: Home, name: "菜單", // leaf: true,//只有一個(gè)節(jié)點(diǎn) iconCls: "el-icon-message", //圖標(biāo)樣式class children: [ { path: "/table", component: Table, name: "子菜單01" } ] } ]; export default routes;
5.main.js實(shí)現(xiàn)
// 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 App from "./App" import VueRouter from "vue-router" import routes from "./routes" import Vuex from "vuex" import store from "./vuex/store" import ElementUI from "element-ui" import "element-ui/lib/theme-chalk/index.css" import Mock from "./mock" Mock.bootstrap(); import "./style/login.css" /* Vue.use(VueAxios, axios) */ Vue.use(ElementUI) Vue.use(VueRouter) Vue.use(Vuex) Vue.config.productionTip = false const router = new VueRouter({ routes }) router.beforeEach((to, from, next) => { //NProgress.start(); if (to.path == "/login") { sessionStorage.removeItem("user"); } let user = JSON.parse(sessionStorage.getItem("user")); if (!user && to.path != "/login") { next({ path: "/login" }) } else { next() } }) new Vue({ router, store, render: h => h(App) }).$mount("#app")
感謝各位的閱讀,以上就是“Vue如何實(shí)現(xiàn)登陸跳轉(zhuǎn)”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Vue如何實(shí)現(xiàn)登陸跳轉(zhuǎn)這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!