This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/mixin/routerPathParams.js

22 lines
602 B
JavaScript
Raw Normal View History

import lodash from 'lodash'
export default {
methods: {
// 解析请求参数,初始化 searchLabel
initQueryFromPath (searchKeys) {
const q = this.$route.query
lodash.forIn(searchKeys, (val, key) => {
let qv = lodash.get(q, key)
if (qv && val.type == 'number') {
qv = lodash.toNumber(qv)
}
qv && this.$set(val.target, val.propertyName, qv)
})
},
// 更新path包含请求参数
updatePath (param, path) {
console.log(param)
this.$router.replace({ path: path, query: param }).catch(err => {})
}
}
}