code
<template>
<div class="app-container">
<iframe style="width:100%;height:500px" :src="iframeSrc" />
</div>
</template>
<script type="text/javascript">
import axios from 'axios'
export default {
name: "",
components: { },
data() {
return {
iframeSrc:''
};
},
created(){
let loginForm={
username: 'admin',
password: 'admin'
}
let token = ''
axios.post(`http://123/api/login`, loginForm)
.then(res => {
token = res.headers.token
}).then(() => {
this.iframeSrc = `http://123/index.jsp/#/home?token=${token}`
})
},
mounted() {
},
methods: {
}
};
</script>
<style type="text/css" scoped>
</style>
说明
-
登录地址 ( post请求 )
http://123/api/login
-
用户名密码
username: 'admin',
password: 'admin'
-
跳转页面地址
http://123/index.jsp/#/home
思路
- 请求登录地址
- 获取登录成功后的token
- 把token拼接到跳转的 页面