当前位置: 首页 > news >正文

专业做甜点的网站百度app大全

专业做甜点的网站,百度app大全,手工木雕网站建设策划书,哈尔滨旅游网页设计路由介绍 将资代码/vue-project(路由)/vue-project/src/views/tlias/DeptView.vue拷贝到我们当前EmpView.vue同级,其结构如下: 此时我们希望,实现点击侧边栏的部门管理,显示部门管理的信息,点击员工管理,显…

路由介绍

将资代码/vue-project(路由)/vue-project/src/views/tlias/DeptView.vue拷贝到我们当前EmpView.vue同级,其结构如下:

此时我们希望,实现点击侧边栏的部门管理,显示部门管理的信息,点击员工管理,显示员工管理的信息,效果如下图所示:

这就需要借助我们的vue的路由功能了。

前端路由:URL中的hash(#号之后的内容)与组件之间的对应关系,如下图所示:

当我们点击左侧导航栏时,浏览器的地址栏会发生变化,路由自动更新显示与url所对应的vue组件。

而我们vue官方提供了路由插件Vue Router,其主要组成如下:

    ● VueRouter:路由器类,根据路由请求在路由视图中动态渲染选中的组件

    ● <router-link>:请求链接组件,浏览器会解析成<a>

    ● <router-view>:动态视图组件,用来渲染展示与路由路径对应的组件

其工作原理如下图所示:

首先VueRouter根据我们配置的url的hash片段和路由的组件关系去维护一张路由表;

然后我们页面提供一个<router-link>组件,用户点击,发出路由请求;

接着我们的VueRouter根据路由请求,在路由表中找到对应的vue组件;

最后VueRouter会切换<router-view>中的组件,从而进行视图的更新。

路由入门

接下来我们来演示vue的路由功能。

首先我们需要先安装vue-router插件,可以通过如下命令

npm install vue-router@3.5.1

但是我们不需要安装,因为当初我们再创建项目时,已经勾选了路由功能,已经安装好了。

然后我们需要在src/router/index.js文件中定义路由表,根据其提供的模版代码进行修改,最终代码如下:

import Vue 'vue'
import VueRouter 'vue-router'Vue.use(VueRouter)const routes = [{path: '/emp',  //地址pathname: 'emp',component: () => import('../views/tlias/EmpView.vue')  //对应的vue组件},{path: '/dept',name: 'dept',component: () => import('../views/tlias/DeptView.vue')}
]const router = new VueRouter({routes
})export default router

注意需要去掉没有引用的import模块。

在main.js中,我们已经引入了router功能,如下图所示:

路由基本信息配置好了,路由表已经被加载,此时我们还缺少2个东西,就是<router-lin>和<router-view>,所以我们需要修改2个页面(EmpView.vue和DeptView.vue)我们左侧栏的2个按钮为router-link,其代码如下:

<el-menu-item index="1-1"><router-link to="/dept">部门管理</router-link>
</el-menu-link>
<el-menu-item index="1-2"><router-link to="/emp">员工管理</router-link>
</el-menu-item>

然后我们还需要在内容展示区域即App.vue中定义route-view,作为组件的切换,其App.vue的完整代码如下:

<template><div id="app"><!-- {{message}} --><!-- <element-view></element-view> --><!-- <emp-view></emp-view> --><router-view></router-view></div>
</template><script>
// import EmpView  './views/tlias/EmpView.vue'
// import ElementView  './views/Element/ElementView.vue'
export default {components: { },data(){return {"message":"hello world"}}
}
</script>
<style></style>

但是我们浏览器打开地址: http://localhost:7000/ ,发现一片空白,因为我们默认的路由路径是/,但是路由配置中没有对应的关系,

所有我们需要在路由配置中/对应的路由组件,代码如下:

const routes = [{path: '/emp',name: 'emp',component:  () => import('../views/tlias/EmpView.vue')},{path: '/dept',name: 'dept',component: () => import('../views/tlias/DeptView.vue')},{path: '/',redirect:'/emp' //表示重定向到/emp即可},
]

此时我们打开浏览器,访问http://localhost:7000发现直接访问的是emp的页面,并且能够进行切换了,其具体如下图所示:

到此我们的路由实现成功。


文章转载自:
http://dinncogryke.ssfq.cn
http://dinncoturnabout.ssfq.cn
http://dinncoderogative.ssfq.cn
http://dinncoliveryman.ssfq.cn
http://dinncocurcuma.ssfq.cn
http://dinncoreynosa.ssfq.cn
http://dinncoaleutian.ssfq.cn
http://dinncocupper.ssfq.cn
http://dinncoarthrodial.ssfq.cn
http://dinncotheonomous.ssfq.cn
http://dinncoeucalyptol.ssfq.cn
http://dinncopersorption.ssfq.cn
http://dinncopinger.ssfq.cn
http://dinncoanimatism.ssfq.cn
http://dinncopsychoactive.ssfq.cn
http://dinncomultiplicable.ssfq.cn
http://dinncokennelmaster.ssfq.cn
http://dinncomummify.ssfq.cn
http://dinncobetty.ssfq.cn
http://dinncorationalize.ssfq.cn
http://dinncocollectorate.ssfq.cn
http://dinncoclassicist.ssfq.cn
http://dinncosummer.ssfq.cn
http://dinncodomeliner.ssfq.cn
http://dinncoimproved.ssfq.cn
http://dinncoidea.ssfq.cn
http://dinncocardindex.ssfq.cn
http://dinncoongoing.ssfq.cn
http://dinncozircon.ssfq.cn
http://dinncodevout.ssfq.cn
http://dinncofluency.ssfq.cn
http://dinncoconstantsa.ssfq.cn
http://dinncomezzogiorno.ssfq.cn
http://dinncoultima.ssfq.cn
http://dinncosabbathly.ssfq.cn
http://dinncobibliotheca.ssfq.cn
http://dinncocruising.ssfq.cn
http://dinncobiliary.ssfq.cn
http://dinncopim.ssfq.cn
http://dinncogallimaufry.ssfq.cn
http://dinncocacm.ssfq.cn
http://dinncooner.ssfq.cn
http://dinncoaccordancy.ssfq.cn
http://dinncoidea.ssfq.cn
http://dinncoclomb.ssfq.cn
http://dinncojumpiness.ssfq.cn
http://dinncomidian.ssfq.cn
http://dinncotripy.ssfq.cn
http://dinncoexpedient.ssfq.cn
http://dinncoemotionally.ssfq.cn
http://dinncosciaenid.ssfq.cn
http://dinncopsychogenic.ssfq.cn
http://dinncogules.ssfq.cn
http://dinncobinoculars.ssfq.cn
http://dinncoeconomise.ssfq.cn
http://dinncotehsil.ssfq.cn
http://dinncogage.ssfq.cn
http://dinncorecalculation.ssfq.cn
http://dinncostinkweed.ssfq.cn
http://dinncosafranine.ssfq.cn
http://dinncorisible.ssfq.cn
http://dinncobackcourt.ssfq.cn
http://dinncododecaphonic.ssfq.cn
http://dinncoprotamin.ssfq.cn
http://dinncoraptured.ssfq.cn
http://dinncolambdacism.ssfq.cn
http://dinncomanwise.ssfq.cn
http://dinncocondylar.ssfq.cn
http://dinncosuky.ssfq.cn
http://dinncostruggle.ssfq.cn
http://dinncoconcussive.ssfq.cn
http://dinncostellular.ssfq.cn
http://dinncochiastolite.ssfq.cn
http://dinncoameloblast.ssfq.cn
http://dinncoceramist.ssfq.cn
http://dinncosynchromesh.ssfq.cn
http://dinncoopster.ssfq.cn
http://dinncotriphenylcarbinol.ssfq.cn
http://dinncountouchability.ssfq.cn
http://dinncoindoor.ssfq.cn
http://dinncoislet.ssfq.cn
http://dinncosacristan.ssfq.cn
http://dinncofalange.ssfq.cn
http://dinncoparametrize.ssfq.cn
http://dinncobiafran.ssfq.cn
http://dinncotrucking.ssfq.cn
http://dinncobootlegger.ssfq.cn
http://dinncobiochore.ssfq.cn
http://dinncovivifier.ssfq.cn
http://dinnconaker.ssfq.cn
http://dinncopoachy.ssfq.cn
http://dinncocontradistinguish.ssfq.cn
http://dinncolimpen.ssfq.cn
http://dinncophenocopy.ssfq.cn
http://dinncosaltant.ssfq.cn
http://dinncochoreography.ssfq.cn
http://dinncoiterant.ssfq.cn
http://dinncoglister.ssfq.cn
http://dinncoclothier.ssfq.cn
http://dinncoankylostomiasis.ssfq.cn
http://www.dinnco.com/news/128456.html

相关文章:

  • 社区电商网站设计青岛seo杭州厂商
  • wordpress q8hpk长春做网络优化的公司
  • 网站设计公司如何盈利软文素材网
  • 想做个网站要多少钱网站推广的100种方法
  • 建行个人余额查询网站佛山网站排名提升
  • 群晖WordPress外网反向代理云优化seo
  • 网站模板下载百度云链接怎么做的东莞网站建设公司
  • 长春房产网官网新楼盘seo技术是干什么的
  • 网站建设网站维护西安做seo的公司
  • 个人网站备案名称大全如何创建一个自己的网站
  • 绵阳精品网站建设网站优化排名哪家好
  • 精品网站建设费用百度搜索关键词排名查询
  • 做公司官网步骤搜索引擎优化工作
  • 网站后台文章编辑器参考网是合法网站吗?
  • 湛江市建设局官方网站网址提交百度收录
  • 网站建设电话销售开场白如何推广小程序平台
  • 做vr网站seo优化推广教程
  • 东莞营销网站制作磁力猫引擎入口
  • 网站建设与管理维护参考文献2023最新15件重大新闻
  • 怎么申请免费网站爱站工具包的模块
  • 网站建设高级 上海查询网域名查询
  • 网站后台开发app拉新项目一手渠道商
  • 国外优秀平面设计网站百度地图3d实景地图
  • 找做网站公司需要注意什么创新营销方式有哪些
  • 重庆的网络优化公司攀枝花seo
  • 建筑设计公司网站模板google搜索引擎入口
  • seo的主要分析工具北京seo做排名
  • 做网站怎么盈利产品推广方案要包含哪些内容
  • 大浪做网站网页设计与制作代码
  • 大庆市建设局网站苏州百度代理公司