【问题标题】:react-suneditor css not loading on productionreact-suneditor css未在生产中加载
【发布时间】:2023-03-03 19:34:01
【问题描述】:

我按照文档中的说明设置了 react-suneditor,使用的是动态加载,因为我使用的是 Next.js。

import React from 'react';
import dynamic from "next/dynamic";
import 'suneditor/dist/css/suneditor.min.css'; // Import Sun Editor's CSS File

const SunEditor = dynamic(() => import("suneditor-react"), {
  ssr: false,
});

const MyComponent = props => {
  return (
    <div>
      <p> My Other Contents </p>
      <SunEditor />
    </div>
  );
};
export default MyComponent;

富文本编辑器在我的 macbook 上开发时可以正常工作并且看起来很好。但是,当我在 Heroku 上推送到我的服务器时,它完全弄乱了样式。不知道是不是加载css有问题?

它在开发中的样子:

它在服务器上的外观:

【问题讨论】:

    标签: reactjs next.js richtextbox suneditor


    【解决方案1】:

    我通过导入源 css 而不是 dist 使其工作:
    import 'suneditor/src/assets/css/suneditor.css'
    但是恕我直言,这只是一种解决方法。

    我建议在https://github.com/mkhstar/suneditor-react 上打开一个问题

    【讨论】:

      猜你喜欢
      • 2011-08-02
      • 1970-01-01
      • 2018-03-09
      • 2020-08-24
      • 1970-01-01
      • 1970-01-01
      • 2023-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多