vue.js中获取url值的方法:1、在【main.js】中写入【path: '/goodsinfo/:goodsId'】;2、在当前文件中设置代码为【
const router = new VueRouter({ routes: [ { path: '/goodsinfo/:goodsId', component: goodsinfo }, ] })二:在当前文件中设置
![]()
{{subitem.artTitle}}
{{subitem.sell_price}}元
库存 {{subitem.stock_quantity}} 市场价:
{{subitem.market_price}}三:在跳转后的文件中获取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); } ); },
上一篇:vue.js监听路由变化的方法
下一篇:vue.js使用jq的方法