我已经克隆了应用程序https://github.com/alanbsmith/react-node-example并尝试使用react-helmet。通过检查浏览器,我可以看到元标记值存在,但是当我在 Facebook 上发布 URL 并尝试在此处查看元标记状态时,https : //developers.facebook.com/tools/debug/sharing/它说属性应该被传递。请任何人都可以建议这里出了什么问题。
请找到我的组件代码,
import '../assets/stylesheets/base.scss';
import React, { Component } from 'react';
import Helmet from "react-helmet";
class App extends Component {
render() {
return(
<div className="application">
<Helmet
htmlAttributes={{"lang": "en", "amp": undefined}} // amp takes no value
title="My Title"
titleTemplate="React Helmet - %s"
defaultTitle="React Helmet Title"
base={{"target": "_blank", "href": "http://myappname.herokuapp.com/"}}
meta={[
{"name": "description", "content": "Helmet application"},
{"property": "fb:app_id", "content": "myfbid"},
{"property": "og:title", "content": "My application title goes here."},
{"property": "og:type", "content": "website"},
{"property": "og:url", "content": "http://myappname.com/"},
{"property": "og:image", "content": "https://imagename.png"},
{"property": "og:description", "content": "Application description"},
{"property": "og:site_name", "content": "MyAppname.com"},
]}
/>
<h1>Welcome to the React helmet App, {this.props.name}!</h1>
</div>
)
}
};
export default App;