您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

vue.js中如何获取url的值

2024/2/27 12:27:23发布18次查看
vue.js中获取url值的方法:1、在【main.js】中写入【path: '/goodsinfo/:goodsid'】;2、在当前文件中设置代码为【 【相关文章推荐:vue.js】
vue.js中获取url值的方法:
一:main.js中写入
const router = new vuerouter({ routes: [ { path: '/goodsinfo/:goodsid', component: goodsinfo }, ]})
二:在当前文件中设置
<template><div><router-link :to="'/goodsinfo/'+ subitem.artid" class=""> <div class="img-box"> <img v-lazy =subitem.img_url> </div> <div class="info"> <h3>{{subitem.arttitle}}</h3> <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中的值
// 获得商品评论数据 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); } ); },
相关免费学习推荐:javascript(视频)
以上就是vue.js中如何获取url的值的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product