首页 > 解决方案 > Material-UI v5 Emotion 错误:您似乎在使用不带引号的 'content' 值,尝试将其替换为 `content: '""'`

问题描述

我从 Material-UI v4 迁移到 v5。现在,无论我尝试渲染基于 Material-UI 的组件,我都会收到此错误:

You seem to be using a value for 'content' without quotes, try replacing it with `content: '""'` 

这似乎是由 v5使用的新样式库 Emotion 引起的。

我发现了一个讨论此错误的 Emotion 的Github 问题,但它对我没有帮助。我不应该摆弄 MUI 如何使用 Emotion,对吧?我希望这种复杂性对我来说是隐藏的。

有想法该怎么解决这个吗?

错误截图

标签: material-ui

解决方案


我需要改变:

  MuiInputBase: {
    root: {
      "&:after": {
        content: "", <--------
        display: "table",
        clear: "both",
      },
    },
  },

  MuiInputBase: {
    root: {
      "&:after": {
        content: '""', <----------
        display: "table",
        clear: "both",
      },
    },
  },

推荐阅读