方式一:
data(){
return{
searchData: {
conditions: {
name: '',
able: 1,
},
page: {
page: 1,
num: 10,
listTotal: 0
}
},
}
}
created () {
this.init()
},
methods: {
init () {
let page = this.$route.query.page
if (page) {
this.getData(parseInt(page))
} else {
this.getData(1)
}
},
}
util.toUrl = function (url, params) {
var paramsArr = []
if (params) {
for (prop in params) {
var val = params[prop]
if (val) {
if (typeof (val) != 'function') {
paramsArr.push(prop + '=' + val)
}
}
}
if (url.search(/\?/) === -1) {
url += '?' + paramsArr.join('&')
} else {
url += '&' + paramsArr.join('&')
}
return url
}
}
edit (item) {
// let url = '/shop/useradd/' + item.storeUser.id+"?page="+this.searchData.page.page
let url = '/shop/useradd/' + item.storeUser.id
url = util.toUrl(url, this.searchData.conditions)
url = util.toUrl(url, this.searchData.page)
this.$router.push({
path: url
})
}
goBack () {
console.log(this.$route.query); // this.$route.query 是拿取路由上面的值
this.$router.push({
path: '/user/custom',
query: this.$route.query
})
},
方式二
data(){
return{
searchData: {
conditions: {
name: '',
able: 1,
},
page: {
page: 1,
num: 10,
listTotal: 0
}
},
}
}
created () {
this.init()
},
methods: {
init () {
let page = this.$route.query.page
if (page) {
this.getData(parseInt(page))
} else {
this.getData(1)
}
},
}
edit (item) {
let url = '/shop/useradd/' + item.storeUser.id+"?page="+this.searchData.page.page
// let url = '/shop/useradd/' + item.storeUser.id
// url = util.toUrl(url, this.searchData.conditions)
// url = util.toUrl(url, this.searchData.page)
this.$router.push({
path: url
})
}
goBack () {
console.log(this.$route.query); // this.$route.query 是拿取路由上面的值
this.$router.push({
path: '/user/custom',
query: this.$route.query
})
},