vue.js中怎么获取url的值(url值,vue.js,的值,编程语言)

时间:2024-04-28 22:02:07 作者 : 石家庄SEO 分类 : 编程语言
  • TAG :

vue.js中获取url值的方法:1、在【main.js】中写入【path: '/goodsinfo/:goodsId'】;2、在当前文件中设置代码为【<router-link :to="'/goodsinfo/'+ subitem.a】。

vue.js中获取url值的方法:

一:main.js中写入

vue.js中怎么获取url的值

const router = new VueRouter({ routes: [ { path: '/goodsinfo/:goodsId', component: goodsinfo }, ]})

二:在当前文件中设置

vue.js中怎么获取url的值

<template><div><router-link :to="'/goodsinfo/'+ subitem.artID" class=""> <div class="img-box"> <img v-lazy =subitem.img_url> </div> <div class="info"> <h4>{{subitem.artTitle}}</h4> <p class="price"> <b>{{subitem.sell_price}}</b>元</p> <p> <strong>库存 {{subitem.stock_quantity}}</strong> <span>市场价: <s>{{subitem.market_price}}</s> </span> </p> </div></router-link></div></template>

三:在跳转后的文件中获取url中的值

vue.js中怎么获取url的值

 // 获得商品评论数据 getCommentByPage() { const url = `site/comment/getbypage/goods/${ this.$route.params.goodsId }?pageIndex=${this.pageIndex}&pageSize=${this.pageSize}`; this.$axios.get(url).then( res => { this.comment = res.data; }, err => { console.log(err); } ); },
 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:vue.js中怎么获取url的值的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:vue.js轻量的原因下一篇:

9 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18