微信H5获取微信文章

发布时间:2024年01月17日

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>

文章来源:https://blog.csdn.net/weixin_46564011/article/details/135650711
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。