yarn add react-code-previewer
npm install react-code-previewer
import { CodePreviewer, MdPreviewer, PreviewLayout } from "react-code-previewer";
ReactDOM.render(
<PreviewLayout>
<MdPreviewer md={installMd}></MdPreviewer>
<CodePreviewer code={code} showCode={true}>
your-component-here
</CodePreviewer>
<MdPreviewer md={apiMd}></MdPreviewer>
</PreviewLayout>,
mountNode
);
如果是要引入.md 文件,要在 webpack.config.js 文件加入下面这段代码,如下所示:
yarn add -D raw-loader
npm install -D raw-loader
rules: [
{
test: /\.md$/,
use: "raw-loader"
},