Reactjs应用程序收到错误此页面正在尝试从未经身份验证的源加载脚本

问题描述 投票:0回答:1

我是reactjs的新手,我的问题是reactjs应用程序何时生效。在我允许加载脚本之前,它不会从wordpress加载图像。请告诉我处理此问题的良好做法或方法,谢谢!

      componentDidMount() {
    Axios.get(wordpressUrl).then(results => {
      this.setState({
        posts: results.data
      });
      console.log(this.state.posts);
    }).catch(error => console.log(error));
  }

this.state.posts是一个包含axios响应结果的数组

https://starocean.whatstreetapp.com/wp/wp-json/wp/v2/posts?_embed

return (
  <div>
    <span className='header'>  Welcome to News Feed!<br /></span>
    <div className="news_container">
    {this.state.posts.map(post => {
      return (
        <div key={post.link} className="post-wrapper" onClick={() => this.newTab(post.link)}>
          <div className="post">

            <h2 className="post-title">
              <a href={post.link} target="_blank"
                dangerouslySetInnerHTML={{ __html: post.title.rendered }}
              />
            </h2>
            {post.featured_media ?
              <a href={post.link}><img src={post._embedded['wp:featuredmedia'][0].media_details.sizes['large'].source_url} /></a>
              : null}
            {post.excerpt.rendered ?
              <div className="excerpt" dangerouslySetInnerHTML={{ __html: post.excerpt.rendered }} />
              : null}
          </div>
        </div>
      );
    })}
    </div>
  </div>
);
wordpress reactjs
1个回答
0
投票

查看此文档:https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content/How_to_fix_website_with_mixed_content

如果您想从https页面提供脚本,您也应该在https页面中提供服务。

© www.soinside.com 2019 - 2024. All rights reserved.