fix: 改造支持传参

develop
时启龙 2024-08-28 17:22:41 +08:00
parent 6611360c9b
commit 953138f7e9
2 changed files with 30 additions and 12 deletions

View File

@ -6,15 +6,24 @@
<script>
import { getToken } from '@cmp/cmp-element'
function addParamsToUrl(url, params) {
const queryString = Object.keys(params)
.map(key => key + '=' + params[key])
.join('&')
// url
const separator = url.includes('?') ? '&' : '?'
return url + separator + queryString
}
export default {
data() {
return {}
},
methods: {},
computed: {
iframeUrl() {
const url = new URL(this.$route.meta.url)
url.searchParams.append('token', getToken())
const params = {
token: getToken(),
...this.$route.query
}
const url = addParamsToUrl(this.$route.meta.url, params)
return url.toString()
}
}

View File

@ -6,15 +6,24 @@
<script>
import { getToken } from '@cmp/cmp-element'
function addParamsToUrl(url, params) {
const queryString = Object.keys(params)
.map(key => key + '=' + params[key])
.join('&')
// url
const separator = url.includes('?') ? '&' : '?'
return url + separator + queryString
}
export default {
data() {
return {}
},
methods: {},
computed: {
iframeUrl() {
const url = new URL(this.$route.meta.url)
url.searchParams.append('token', getToken())
const params = {
token: getToken(),
...this.$route.query
}
const url = addParamsToUrl(this.$route.meta.url, params)
return url.toString()
}
}