vue2 支付寶 網頁支付 返回form 表單的解決
.then(res => {
if(res.status === 20000 && this.form.type == 2){
//返回引數
let routerData = this.$ router.resolve({path:'/ finance / applyText',query:{htmls:res.data.result}})
this.htmls = res.data.result
//開啟新頁面
window.open(routerData.href,'_ blank')
const div = document.createElement('div');
div.innerHTML = htmls;
document.body.appendChild(div);
document.forms [0] .submit();
}
})
新的vue頁面程式碼applyText.vue
<template>
<div v-html =“apply”>
{{apply}}
</ div>
</ template>
<script>
export default {
name:“applyText”,
data(){
return {
apply:''
}
} ,
mounted(){
let form = this。$ route.query.htmls
this.apply = form;
this.$ nextTick(()=> {
document.forms [0] .submit()
})
}
}
</ script>
<style scoped>
</ style>