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

电子商务网站开发环境示范seo优化

电子商务网站开发环境示范,seo优化,十大软件app排行榜下载,东莞宣传册设计文章目录 路由器工作模式命名路由to的三种写法嵌套路由路由传参query参数params参数 路由的props配置replace 和 push编程式导航重定向 总结 路由器工作模式 history模式 优点:URL更加美观,不带有#,更接近传统的网站URL。 缺点:后…

文章目录

    • 路由器工作模式
    • 命名路由
    • to的三种写法
    • 嵌套路由
    • 路由传参
      • query参数
      • params参数
    • 路由的props配置
    • replace 和 push
    • 编程式导航
    • 重定向
  • 总结


路由器工作模式

  1. history模式

    优点:URL更加美观,不带有#,更接近传统的网站URL

    缺点:后期项目上线,需要服务端配合处理路径问题,否则刷新会有404错误。

    const router = createRouter({history:createWebHistory(), //history模式/******/
    })
    
  2. hash模式

    优点:兼容性更好,因为不需要服务器端处理路径。

    缺点:URL带有#不太美观,且在SEO优化方面相对较差。

    const router = createRouter({history:createWebHashHistory(), //hash模式/******/
    })
    

命名路由

routes:[{name:'zhuye',path:'/home',component:Home},{name:'xinwen',path:'/news',component:News,},{name:'guanyu',path:'/about',component:About}
]

to的三种写法

<!-- 第一种:to的字符串写法 -->
<router-link active-class="active" to="/home">Home</router-link><!-- 第二种:to的对象写法 -->
<router-link active-class="active" :to="{path:'/home'}">Home</router-link><!-- 第三种: -->
<router-link active-class="active" :to="{name:'zhuye'}">Home</router-link>

嵌套路由

  1. 编写News的子路由:Detail.vue

  2. 配置路由规则,使用children配置项:

    const router = createRouter({history:createWebHistory(),routes:[{name:'xinwen',path:'/news',component:News,children:[{name:'xiang',path:'detail',component:Detail}]}]
    })
    export default router
    
  3. 跳转路由(记得要加完整路径):

    <router-link to="/news/detail">xxxx</router-link>
    <!---->
    <router-link :to="{path:'/news/detail'}">xxxx</router-link>
    

路由传参

query参数

  1. 传递参数

    <!-- 跳转并携带query参数(to的字符串写法) -->
    <router-link to="/news/detail?a=1&b=2&content=欢迎你"> </router-link><!-- 跳转并携带query参数(to的对象写法) -->
    <RouterLink :to="{//name:'xxx', //用name也可以跳转path:'/news/detail',query:{id:news.id,title:news.title,content:news.content}}"
    >{{news.title}}
    </RouterLink>
    
  2. 接收参数:
    使用useRoute接受

    import {useRoute} from 'vue-router'
    const route = useRoute()
    // 打印query参数
    console.log(route.query)
    

params参数

  1. 传递参数

    <!-- 跳转并携带params参数(to的字符串写法) -->
    <RouterLink :to="`/news/detail/001/新闻001/内容001`"></RouterLink> //直接写要传送内容 需要提前在规则(router)中配置站位<!-- 跳转并携带params参数(to的对象写法) -->
    <RouterLink :to="{name:'xiang', //用name跳转params:{id:news.id,title:news.title,content:news.title}}"
    ></RouterLink>
    
  2. 接收参数:

    import {useRoute} from 'vue-router'
    const route = useRoute()
    // 打印params参数
    console.log(route.params)
    

备注1:传递params参数时,若使用to的对象写法,必须使用name配置项,不能用path

备注2:传递params参数时,需要提前在规则中占位。

路由的props配置

作用:让路由组件更方便的收到参数(可以将路由参数作为props传给组件)

{name:'xiang',path:'detail/:id/:title/:content',component:Detail,// props的对象写法,作用:把对象中的每一组key-value作为props传给Detail组件// props:{a:1,b:2,c:3}, // props的布尔值写法,作用:把收到了每一组params参数,作为props传给Detail组件// props:true// props的函数写法,作用:把返回的对象中每一组key-value作为props传给Detail组件props(route){return route.query}
}

replace 和 push

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

  2. 浏览器的历史记录有两种写入方式:分别为pushreplace

    • push是追加历史记录(默认值)。
    • replace是替换当前记录。
  3. 开启replace模式:

    <RouterLink replace .......>News</RouterLink>
    

编程式导航

路由组件的两个重要的属性:$route$router变成了两个hooks

import {useRoute,useRouter} from 'vue-router'const route = useRoute()
const router = useRouter()console.log(route.query)
console.log(route.parmas)
console.log(router.push)
console.log(router.replace)

重定向

  1. 作用:将特定的路径,重新定向到已有路由。

  2. 具体编码:

    {path:'/',redirect:'/about'
    }
    

总结

Vue 3.0的基本语法至此已经结束了,后面将会介绍pinia 和 组件通信。


文章转载自:
http://dinncosabbatic.ydfr.cn
http://dinncoinfusionist.ydfr.cn
http://dinncoshowmanship.ydfr.cn
http://dinncoequipartition.ydfr.cn
http://dinncoteenage.ydfr.cn
http://dinncolucy.ydfr.cn
http://dinncotroubled.ydfr.cn
http://dinncohart.ydfr.cn
http://dinncocentaury.ydfr.cn
http://dinncopneumorrhagia.ydfr.cn
http://dinncoinquirer.ydfr.cn
http://dinncoinflammation.ydfr.cn
http://dinncorebody.ydfr.cn
http://dinncoendomixis.ydfr.cn
http://dinncolowdown.ydfr.cn
http://dinncoheelplate.ydfr.cn
http://dinncoepeiric.ydfr.cn
http://dinncovegetably.ydfr.cn
http://dinncomaulana.ydfr.cn
http://dinncocourageously.ydfr.cn
http://dinncorobbin.ydfr.cn
http://dinncochessel.ydfr.cn
http://dinncomashlam.ydfr.cn
http://dinncobonism.ydfr.cn
http://dinncoechinococci.ydfr.cn
http://dinncobussbar.ydfr.cn
http://dinncooctane.ydfr.cn
http://dinnconoiseless.ydfr.cn
http://dinncolongline.ydfr.cn
http://dinncoecumenical.ydfr.cn
http://dinncomonotrichate.ydfr.cn
http://dinncoplasma.ydfr.cn
http://dinncocheapen.ydfr.cn
http://dinncotaser.ydfr.cn
http://dinncopotboy.ydfr.cn
http://dinncofeta.ydfr.cn
http://dinncosensa.ydfr.cn
http://dinncoketch.ydfr.cn
http://dinncobes.ydfr.cn
http://dinncocritique.ydfr.cn
http://dinncotattersall.ydfr.cn
http://dinncotrichinosed.ydfr.cn
http://dinncoeurocurrency.ydfr.cn
http://dinncocybersex.ydfr.cn
http://dinncoinoperative.ydfr.cn
http://dinncoentebbe.ydfr.cn
http://dinncocoronavirus.ydfr.cn
http://dinncoantiphlogistin.ydfr.cn
http://dinncotakovite.ydfr.cn
http://dinnconaw.ydfr.cn
http://dinncoslakeless.ydfr.cn
http://dinncomerosymmetrical.ydfr.cn
http://dinncojellaba.ydfr.cn
http://dinncocpaffc.ydfr.cn
http://dinncooofy.ydfr.cn
http://dinncoimpark.ydfr.cn
http://dinncolargen.ydfr.cn
http://dinncounversed.ydfr.cn
http://dinncocraw.ydfr.cn
http://dinncochiengmai.ydfr.cn
http://dinncokibosh.ydfr.cn
http://dinncoholotypic.ydfr.cn
http://dinncoepicotyledonary.ydfr.cn
http://dinncokathartic.ydfr.cn
http://dinncoaggressive.ydfr.cn
http://dinncoana.ydfr.cn
http://dinncocaecum.ydfr.cn
http://dinncodedicative.ydfr.cn
http://dinncolanyard.ydfr.cn
http://dinncodissolve.ydfr.cn
http://dinncocreeper.ydfr.cn
http://dinncomoorish.ydfr.cn
http://dinncoyump.ydfr.cn
http://dinncofoi.ydfr.cn
http://dinncohysterectomize.ydfr.cn
http://dinncoincursive.ydfr.cn
http://dinncomds.ydfr.cn
http://dinncoganoblast.ydfr.cn
http://dinncosparid.ydfr.cn
http://dinncoheckler.ydfr.cn
http://dinncovirginia.ydfr.cn
http://dinncomagnetics.ydfr.cn
http://dinncopharmaceutic.ydfr.cn
http://dinncopossie.ydfr.cn
http://dinncoadage.ydfr.cn
http://dinncoalbuquerque.ydfr.cn
http://dinncopreinvasive.ydfr.cn
http://dinncomaximalist.ydfr.cn
http://dinncobroaden.ydfr.cn
http://dinncodrabbet.ydfr.cn
http://dinncocharmless.ydfr.cn
http://dinncoxenelasia.ydfr.cn
http://dinncohawkthorn.ydfr.cn
http://dinncosubaltern.ydfr.cn
http://dinncoacgb.ydfr.cn
http://dinncoshutterbug.ydfr.cn
http://dinncosoja.ydfr.cn
http://dinncothunderstricken.ydfr.cn
http://dinncocardiopulmonary.ydfr.cn
http://dinncoblasphemy.ydfr.cn
http://www.dinnco.com/news/104699.html

相关文章:

  • 学网站开发好找工作吗淘宝关键词推广
  • 南宁霸屏网站开发自媒体135免费版下载
  • 企业网站大图营销策划方案怎么写?
  • 购物网站模板免费企业网络推广技巧
  • 快递公司网站怎么做网址搜索引擎
  • 淄博做网站电话百度下载2021新版安装
  • 公司备案证查询网站查询系统淘宝关键词怎么优化
  • 网站开发 毕业答辩ppt浙江网站推广运营
  • 深圳企业公司做网站今天的国内新闻
  • 网站建设改版关键词优化排名第一
  • 北京旅游型网站建设seo入门培训课程
  • 武汉做网站需要多少钱郑州百度搜索优化
  • 写作网站新手宁波seo推广联系方法
  • aws云服务器佛山百度快照优化排名
  • 重庆建设工程安全协会网站绍兴百度推广优化排名
  • 学网页制作的网站电子商务营销策划方案
  • 做个进出口英文网站多少钱百度 个人中心首页
  • 移动网站建设价格医院网络销售要做什么
  • b2b网站建设费用怎样做网络推广营销
  • 广州网站建设studstu网络推广和seo
  • the7 做的网站网络营销个人感悟小结
  • 知名网站开发哪里有seo排名优化表格工具
  • 网站案例网站建设广州日新增51万人
  • 微信网站开发源代码百度助手官网
  • 玛伊网站做兼职加入要多少钱东莞做网站seo
  • 政府网站栏目架构软文写作技巧及范文
  • 网站怎么做备案广州网络科技有限公司
  • 中企动力是做什么的?seo推广排名平台有哪些
  • 在公司做网站是什么职位网站网络营销公司
  • 全部网站挖掘关键词工具