javascript - 如何在 JWPlayer 的错误消息中隐藏错误代码?
问题描述
我有一个如下所示的 React 代码,它呈现播放器。在下面的代码中,我将 ReactJWPlayer 组件与他们的 props 一起使用。为了配置intl.{lang}.errors,我使用了react-jw-player公开的 customProps 选项
const ReactJWPlayerContainer = props => {
const [error, setError] = useState("");
const [errorNode, setErrorNode] = useState(null);
const player = ()=> {
return (
<ReactJWPlayer
playlist={[props.playlist]}
customProps={{
intl: {
en: {
errors: {
badConnection: "This video cannot be played because of a problem with your internet connection.",
cantLoadPlayer: "Sorry, the video player failed to load.",
},
},
fr: {
errors: {
badConnection: "This video cannot be played because of a problem with your internet connection.",
cantLoadPlayer: "Sorry, the video player failed to load.",
},
},
},
}}
/>
)
}
}
return (
<>
{props.playlist && player()}
</>
)
}
如果播放器加载失败,上面的代码会成功显示带有相应错误代码的自定义错误消息。
问题陈述:
我想知道我需要在上面的 React 代码中进行哪些更改才能成功隐藏错误代码。在下面的屏幕截图中,我想隐藏该行 (Error Code: 232011)
解决方案
您必须将 props.playlist 作为变量传递,但要作为数组项传递。
将此代码 playlist={[props.playlist]} 更改为 playlist={props.playlist}
我假设 props.playlist 是一个像这个例子一样的数组:
https://github.com/micnews/react-jw-player#playing-a-custom-playlist
推荐阅读
- python - 混淆矩阵 - Python
- stripe-payments - 是否可以将项目添加到付款意图?
- react-native - React Native:从导航堆栈中删除当前屏幕,维护以前的屏幕
- python - Selenium 不会在看起来像弹出窗口的地方找到元素
- c# - 保存资产时Unity Broken text PPtr
- html - 如何在 Marp 或 Marpit 中对齐文本标题下方的图像
- html - Django将单词添加到图像url
- wordpress - Wordpress 如何将自定义帖子类型直接链接到自定义字段而不是父帖子页面
- docker - FirewallD 阻止到 Docker 容器的入站连接 OpenSUSE Leap 15.3
- javascript - 按住箭头键在反应中滚动网格