iframe嵌套微信公众号文章 - 掘金 (juejin.cn)?大佬的
<script setup>
import {useRoute} from "vue-router";
import {getCurrentInstance} from "vue";
const {proxy}=getCurrentInstance();
const route=useRoute();
function getUrl(URL) {
URL=URL.substring(URL.indexOf('/s'),URL.length)
console.log(URL)
proxy.$axios({
url: URL,
method: 'get',}).then(res=>{
console.log(res)
let html = res.data;
html = html.replace(/data-src/g, "src")
.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/g, '')
.replace(/https/g, 'http');
// let html_src = 'data:text/html;charset=utf-8,' + html;
let html_src = html;
let iframe = document.getElementById('iFrame');
iframe.src = html_src;
var doc = iframe.contentDocument || iframe.document;
doc.write(html_src);
doc.getElementById("js_content").style.visibility = "visible";
})
}
getUrl(route.query.id);
</script>
<template>
<div style="width: 100%;height: 100%;">
<iframe style="width: 100%;height: 100%;" id="iFrame"></iframe>
</div>
</template>
<style scoped>
</style>