|
Post by account_disabled on Jan 28, 2024 4:54:15 GMT -6
我们将把页面标题添加到<title>文档的标签中。 除了这个高级组件中的一些渲染逻辑之外,我们还包含了该getMoreArticles方法。这是存储在较高级别组件中并通过 props 可供较低级别组件使用的号召性用语的一个很好的示例。 现在让我们进入我们的BlogList组件看看它是如何工作的。 创建一个名为 的新文件夹Partials。然后,在其中创建一个名为BlogList.js以下内容的文件在我们的BlogList组件中,我们onClick向Show More Articles按钮添加了一个事件。后者执行getMoreArticles从更高级别的页面组件作为 props 传递下来的方法。 单击该按钮时,事件会向上冒泡到Blog组件,然后触发 上的操作AppDispatcher。AppDispatcher充当我们的高 WhatsApp 号码数据 层组件和我们的组件之间的中间人AppStore. 为了简洁起见,我们不会在本教程中构建所有 和Page组件Partial,因此请下载 GitHub 存储库并从文件夹中添加它们components。 应用调度程序 它AppDispatcher是我们应用程序中的运算符,它从更高级别的组件接受信息并将操作分发到存储,然后存储重新呈现我们的应用程序数据。 要继续本教程,请创建一个名为 的文件夹dispatcher。 在其中创建一个名为 的文件AppDispatcher.js,其中包含以下代码我们现在可以在开发模式下运行热重载,也可以在生产模式下运行服务器渲染标记。运行以下命令以在生产模式下运行完整的 React 通用博客应用程序: npm start 我们的博客现在可以在http://localhost:3000上查看。它可以在服务器端、浏览器端查看,并且我们的内容可以通过我们的云托管内容平台Cosmic JS进行管理。
|
|