1

现在,我正在使用Reaction Commerce 1.10。我想创建一个自定义插件并重写页脚,但不知道该怎么做。

这是页脚代码:

import React from "react";
import { registerComponent } from "/imports/plugins/core/components/lib";

const Footer = () => (
  <div className="reaction-navigation-footer footer-default">
    <nav className="navbar-bottom">
      <div className="row">
        {/* Footer content */}
      </div>
    </nav>
  </div>
);

registerComponent("Footer", Footer);

export default Footer;
4

1 回答 1

1

您可以通过首先创建自定义插件来做到这一点:

reaction plugins create --name your-footer-plugin

然后,components/imports/plugins/custom/your-footer-plugin/client.

/imports/plugins/custom/your-footer-plugin/client/components中,创建一个Footer.jsx文件。

在此文件中,使用组件 API 将组件替换为Footer您想要的组件:

import React from "react";
import { replaceComponent } from "@reactioncommerce/reaction-components";

const Footer = () => (
  <footer>
    <p>This is your new, custom footer.</p>
  </footer>
);

replaceComponent("Footer", Footer);

最后,确保您创建了一个index.js文件/imports/plugins/custom/your-footer-plugin/client/components来导入您的组件:

import "./Footer";

另一个index.js用于/imports/plugins/custom/your-footer-plugin/client导入component目录的索引:

import "./components";

确保重新启动 Reaction 以reaction reset -n && reaction使这些更改生效。

于 2018-07-26T18:12:43.607 回答