【问题标题】:Why are styles from react-syntax-highlighter/dist/esm/styles/prism not working as expected?为什么 react-syntax-highlighter/dist/esm/styles/prism 中的样式不能按预期工作?
【发布时间】:2021-07-09 04:48:54
【问题描述】:

这是我的代码

import SyntaxHighlighter from "react-syntax-highlighter";
import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";

const App = () => {
  const x = `
  for (let i = 0; i < haystack.length; i++) {
    if (!haystack[i] === needle) return;
  }
  `;
  return (
    <SyntaxHighlighter
      language="javascript"
      style={vscDarkPlus}
      showLineNumbers={true}
      codeTagProps={{ style: { fontSize: "inherit" } }}
      customStyle={{ fontSize: 18 }}
    >
      {x}
    </SyntaxHighlighter>
  );
};

当我想使用 vscDarkPlus 风格时,我会得到这样的图片

为什么 react-syntax-highlighter / dist / esm / styles / prism 中的样式无法按预期工作?

【问题讨论】:

    标签: reactjs react-syntax-highlighter


    【解决方案1】:
    import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
    

    【讨论】:

      猜你喜欢
      • 2021-03-10
      • 2019-06-29
      • 2021-05-30
      • 2020-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多