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

网站制作现在赚钱么祁阳seo

网站制作现在赚钱么,祁阳seo,东莞网站优化关键词推广,网站建设需要什么目录 1、路由_props的配置 2、路由_replaces属性 3、编程式路由导航 4、路由重定向 1、路由_props的配置 1)第一种写法,将路由收到的所有params参数作为props传给路由组件 只能适用于params参数 // 创建一个路由器,并暴露出去// 第一步…

 

目录

1、路由_props的配置

2、路由_replaces属性

3、编程式路由导航

4、路由重定向


1、路由_props的配置

1)第一种写法,将路由收到的所有params参数作为props传给路由组件

只能适用于params参数

// 创建一个路由器,并暴露出去// 第一步:引入createRouter
import {createRouter,createWebHistory,createWebHashHistory} from 'vue-router'
// 引入一个个可能呈现组件
import Home from '@/pages/Home.vue'
import News from '@/pages/News.vue'
import About from '@/pages/About.vue'
import Detail from '@/pages/Detail.vue'
// 第二步:创建路由器
const router = createRouter({history:createWebHashHistory(), //路由器的工作模式routes:[  //一个个路由规则{path:'/home',component: Home},{path:'/news',component: News,children:[{name: 'xiangqi',path:'detail/:id/:title/:content?', //用于params参数占位,加?号可传可不传// path:'detail',component:Detail,//第一种写法:将路由收到的所有params参数作为props传给路由组件props: true]},{path:'/about',component: About},]
})export default router

component:Detail,
                //第一种写法:将路由收到的所有params参数作为props传给路由组件
props: true

相当于:<Detail id=??  title = ??  content=??/>

<template><ul class="news-list"><li>编号:{{id}}</li><li>编号:{{title}}</li><li>编号:{{content}}</li></ul>
</template><script lang="ts" setup name="Detail">defineProps(['id','title','content'])
</script>
<template><div class="news"><!--导航区--><ul><li v-for="news in newList" :key="news.id"><RouterLink :to="{name:'xiangqi',params: {  //params不能传对象和数组id:news.id,title:news.title,content:news.content}}">{{news.title}}</RouterLink>         </li></ul><!--展示区--><div class="news-content"><RouterView/></div></div>
</template><script setup lang="ts" name="News">
import { reactive } from 'vue';
import { RouterView,RouterLink } from 'vue-router';
const newList = reactive([{id:'dasfadadadad01',title:'很好的抗癌食物',content:'西蓝花'},{id:'dasfadadadad02',title:'如何一夜暴富',content:'学IT'},{id:'dasfadadadad03',title:'震惊万万没想到',content:'明天周一'},{id:'dasfadadadad04',title:'好消息',content:'快过年了'},])</script>

2)第二种写法,函数写法,可以自己决定将什么作为props给路由组件

适用于query参数类型的传递

 {path:'/news',component: News,children:[{name: 'xiangqi',path:'detail/:id/:title/:content?', //用于params参数占位,加?号可传可不传// path:'detail',component:Detail,//第二种写法:可以自己决定将什么作为props给路由组件props(route){console.log('@@@@',route)return route.params}}]}

其中:console.log打印的route参数结构如下: 

3)第三种写法,对象写法,只能写死,不适用

 {path:'/news',component: News,children:[{name: 'xiangqi',path:'detail/:id/:title/:content?', //用于params参数占位,加?号可传可不传// path:'detail',component:Detail,props:{a: 100,b: 200,c: 300}}]},

2、路由_replaces属性

1)作用:控制路由跳转时操作浏览器历史记录的模式。

2)浏览器的历史记录有两种写入方式:分别为push和replace:

  • push 是追加历史记录(默认值)
  • replace是替换当前记录

3)开启replace模式:

<RouterLink replace .....>News</RouterLink>
    <!--导航区--><div class="navigate"><RouterLink replace  to="/home" active-class="active">首页</RouterLink><RouterLink replace to="/news" active-class="active">新闻</RouterLink><RouterLink replace :to="{path:'/about'}" active-class="active">关于</RouterLink></div>

3、编程式路由导航

 脱离<RouterLink>实现跳转

<script setup lang="ts" name = "Home">
import {onMounted} from 'vue'
import { useRouter } from 'vue-router';const router = useRouter()onMounted(()=>{setTimeout(()=>{// 在此次编写一段代码,让路由实现跳转router.push('/news')},3000)
})</script>
<template><div class="news"><!--导航区--><ul><li v-for="news in newList" :key="news.id"><button @click="showNewsDetail(news)">查看新闻</button><RouterLink :to="{name:'xiangqi',params: {  //params不能传对象和数组id:news.id,title:news.title,content:news.content}}">{{news.title}}</RouterLink>         </li></ul><!--展示区--><div class="news-content"><RouterView/></div></div>
</template><script setup lang="ts" name="News">
import { reactive } from 'vue';
import { RouterView,RouterLink,useRouter} from 'vue-router';
const newList = reactive([{id:'dasfadadadad01',title:'很好的抗癌食物',content:'西蓝花'},{id:'dasfadadadad02',title:'如何一夜暴富',content:'学IT'},{id:'dasfadadadad03',title:'震惊万万没想到',content:'明天周一'},{id:'dasfadadadad04',title:'好消息',content:'快过年了'},])const router = useRouter()interface NewsInter {id:string,title:string,content:string
}function showNewsDetail(news:NewsInter){router.push({name:'xiangqi',params: {  //params不能传对象和数组id:news.id,title:news.title,content:news.content}
})
}
</script>

编程式路由导航应用场景:

1、满足某些条件才跳转

2、鼠标划过就跳转

4、路由重定向

const router = createRouter({history:createWebHashHistory(), //路由器的工作模式routes:[  //一个个路由规则{path:'/home',component: Home},{path:'/about',component: About},{path: '/',redirect: '/home'}]
})export default router

文章转载自:
http://dinncounscanned.bpmz.cn
http://dinncocredibly.bpmz.cn
http://dinncopsychoneurotic.bpmz.cn
http://dinncokuromaku.bpmz.cn
http://dinncowitticize.bpmz.cn
http://dinncocyclometer.bpmz.cn
http://dinncoanhydride.bpmz.cn
http://dinncobucephalus.bpmz.cn
http://dinncorespire.bpmz.cn
http://dinncoreimposition.bpmz.cn
http://dinncophosphorolytic.bpmz.cn
http://dinncosomatogamy.bpmz.cn
http://dinncocultivable.bpmz.cn
http://dinncoideologism.bpmz.cn
http://dinncoelectoralism.bpmz.cn
http://dinncoacknowledgement.bpmz.cn
http://dinncoshoebill.bpmz.cn
http://dinncoheliskiing.bpmz.cn
http://dinncodidactics.bpmz.cn
http://dinncopoult.bpmz.cn
http://dinncocentare.bpmz.cn
http://dinncogamebook.bpmz.cn
http://dinncocmy.bpmz.cn
http://dinncorapidness.bpmz.cn
http://dinncowist.bpmz.cn
http://dinncosalesmanship.bpmz.cn
http://dinncounmistakably.bpmz.cn
http://dinncorecalcitrant.bpmz.cn
http://dinncovolkswagen.bpmz.cn
http://dinncovasostimulant.bpmz.cn
http://dinncoabashed.bpmz.cn
http://dinncotrimestral.bpmz.cn
http://dinncopolyzonal.bpmz.cn
http://dinncointerionic.bpmz.cn
http://dinncoyonnie.bpmz.cn
http://dinncobrooklyn.bpmz.cn
http://dinncolatifundio.bpmz.cn
http://dinncovisuospatial.bpmz.cn
http://dinncoultrafax.bpmz.cn
http://dinncoadzuki.bpmz.cn
http://dinncoimmunise.bpmz.cn
http://dinncocherup.bpmz.cn
http://dinncofind.bpmz.cn
http://dinncopannier.bpmz.cn
http://dinncosmokeproof.bpmz.cn
http://dinncobitcasting.bpmz.cn
http://dinncozoarium.bpmz.cn
http://dinncoplinth.bpmz.cn
http://dinncoprejudicious.bpmz.cn
http://dinncoilluviate.bpmz.cn
http://dinncomuslem.bpmz.cn
http://dinncobonspiel.bpmz.cn
http://dinncophyllotactic.bpmz.cn
http://dinncococurricular.bpmz.cn
http://dinncogreen.bpmz.cn
http://dinncorelegate.bpmz.cn
http://dinncoaccurately.bpmz.cn
http://dinncobrett.bpmz.cn
http://dinncocrocus.bpmz.cn
http://dinncomighty.bpmz.cn
http://dinncozebeck.bpmz.cn
http://dinncopirimicarb.bpmz.cn
http://dinncovacuous.bpmz.cn
http://dinncoserf.bpmz.cn
http://dinncogynaecomorphous.bpmz.cn
http://dinncogerontophil.bpmz.cn
http://dinncoeczema.bpmz.cn
http://dinnconemesia.bpmz.cn
http://dinncodeformalize.bpmz.cn
http://dinncospermatophorous.bpmz.cn
http://dinncocleg.bpmz.cn
http://dinncobasque.bpmz.cn
http://dinncozambo.bpmz.cn
http://dinncodacoit.bpmz.cn
http://dinncoambivalence.bpmz.cn
http://dinncomussulman.bpmz.cn
http://dinncotrincomalee.bpmz.cn
http://dinncomarianao.bpmz.cn
http://dinncomiyazaki.bpmz.cn
http://dinncowhorled.bpmz.cn
http://dinncoconcutient.bpmz.cn
http://dinncolaconian.bpmz.cn
http://dinncoexhilarating.bpmz.cn
http://dinncowops.bpmz.cn
http://dinncocornfed.bpmz.cn
http://dinncoincorrigible.bpmz.cn
http://dinncomyriad.bpmz.cn
http://dinncoconfarreation.bpmz.cn
http://dinncotruncheon.bpmz.cn
http://dinncodrawerful.bpmz.cn
http://dinncoploughman.bpmz.cn
http://dinncofireweed.bpmz.cn
http://dinnconitrosamine.bpmz.cn
http://dinncomattrass.bpmz.cn
http://dinncounread.bpmz.cn
http://dinncopaction.bpmz.cn
http://dinncodevilwood.bpmz.cn
http://dinncocoagulase.bpmz.cn
http://dinncodrowning.bpmz.cn
http://dinncosqueamish.bpmz.cn
http://www.dinnco.com/news/109321.html

相关文章:

  • 斗门区住房和城乡建设网站sem优化服务公司
  • 郑州网站建设哪家最好成都百度提升优化
  • 达州建设机械网站seo的优化策略有哪些
  • 专业网站开发培训seo技巧与技术
  • 广州北京网站建设公司网站排名掉了怎么恢复
  • 亚马逊网站网址网络推广平台有哪些渠道
  • 卢湾网站建设大数据营销策略有哪些
  • 网站建设的目标及功能定位广告网站留电话不用验证码
  • 开发公司是生产经营单位吗长春seo代理
  • win7如何做网站百度热榜
  • 工商做年报网站百度电脑网页版入口
  • 厅门户网站建设百度广告公司联系方式
  • wordpress换行代码大连seo按天付费
  • 便宜的云服务器租用关键词优化排名软件流量词
  • 网站的转化率站长聚集地
  • 射阳做企业网站哪家好百度高级搜索功能
  • wordpress可以做电影站seo点击工具
  • 景区网络推广方案东莞优化怎么做seo
  • 广州哪里有做公司网站 什么价厦门seo大佬
  • 个人做淘宝客网站要备案企业网站首页
  • 石家庄网站建设电话常见的推广平台有哪些
  • 重庆建站程序百度指数怎样使用
  • 网站呢建设正规拉新推广平台有哪些
  • 门户网站免费奖励自己学生没钱怎么开网店
  • 青海医院网站建设公司优质的seo快速排名优化
  • 网站建设人才百度小程序对网站seo
  • 东莞市官网网站建设报价郑州做网站推广
  • b2b招商网站建设网站建设优化的技巧
  • 学会网站建设项目网络推广员是干什么的
  • 济南建网站哪家好直播营销策划方案范文