最近做了一个公司网站,由于没有后端,只能先写静态页面,新闻内容来源于公众号文章,文章实在是太多了,而且排版内容通过人工复制也工作量巨大,于是想通过iframe嵌入来实现展示。
在新闻文章页面插入html和js就可以了。
function getUrl(URL) {
let http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
//调用跨域API
let realurl = http + '//cors-anywhere.herokuapp.com/' + URL;
axios.get(realurl).then((response) => {
// console.log(response)
let html = response.data;
html = html.replace(/data-src/g, "src")
.replace(/