vue.js中怎么获取url的值
导读:本文共1225字符,通常情况下阅读需要4分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: vue.js中获取url值的方法:1、在【main.js】中写入【path: '/goodsinfo/:goodsId'】;2、在当前文件中设置代码为【<router-link :to="'/goodsinfo/'+ subitem.a】。vue.js中获取url值的方法:一:main.js中写入const rou... ...
音频解说
目录
(为您整理了一些要点),点击可以直达。vue.js中获取url值的方法:1、在【main.js】中写入【path: '/goodsinfo/:goodsId'】;2、在当前文件中设置代码为【<router-link :to="'/goodsinfo/'+ subitem.a】。
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"> <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中的值
// 获得商品评论数据 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的值的详细内容,希望对您有所帮助,信息来源于网络。