控制台报错it looks like an unknown prop “***“ is being sent through to the DOM

自定义组件传输变量时报警告

it looks like an unknown prop “***” is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via (connect an API like @emotion/is-prop-valid) or consider using transient props ($ prefix for automatic filtering.)

控制台报错it looks like an unknown prop “***“ is being sent through to the DOM_第1张图片

意思是我们向DOM传输了一个未知的prop变量,触发了React的警告,想要消除警告我们可以安装类似于@emotion/is-prop-valid的插件或者在传入的变量前加$符号,我这里采用加$符号解决(注意从props取值时也要加$

改之前

  • 传入
    在这里插入图片描述
  • 使用
    在这里插入图片描述

改之后

  • 传入
    在这里插入图片描述
  • 使用
    在这里插入图片描述

你可能感兴趣的:(报错,javascript,前端,开发语言)