小編給大家分享一下vue.js中怎么獲取url的值,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
vue.js中獲取url值的方法:1、在【main.js】中寫入【path: '/goodsinfo/:goodsId'】;2、在當(dāng)前文件中設(shè)置代碼為【<router-link :to="'/goodsinfo/'+ subitem.a】。
vue.js中獲取url值的方法:
一:main.js中寫入
const router = new VueRouter({ routes: [ { path: '/goodsinfo/:goodsId', component: goodsinfo }, ] })
二:在當(dāng)前文件中設(shè)置
<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>市場價(jià): <s>{{subitem.market_price}}</s> </span> </p> </div> </router-link> </div> </template>
三:在跳轉(zhuǎn)后的文件中獲取url中的值
// 獲得商品評論數(shù)據(jù) 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中怎么獲取url的值”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
文章題目:vue.js中怎么獲取url的值-創(chuàng)新互聯(lián)
網(wǎng)站網(wǎng)址:http://m.newbst.com/article12/dcspdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、小程序開發(fā)、網(wǎng)站制作、網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容