在react中使用chartjs出现的错误:”devScripts.js:5836 Warning: Failed prop type: Invalid prop `height` of type“

Failed prop type: Invalid prop height of type

翻译过来的意思就是 height 属性输入的类型是无效的。

这句话怎么理解呢?

简单来讲就是 height 属性值输入的类型错误,你需要检查一下,此处的数据类型是什么,而你又写了什么。

转入详情,错误如下:

 <div style={
    
    {
    
     height: '100%', width: '100%' }}>
 	{
    
    /*  这里的 height 的属性值是 string类型,而实际上他需要 number类型 */}
   <Bar data={
    
    data} width={
    
    Width} height="250" />
 </div>

纠正错误,更改结果如下:

 <div style={
    
    {
    
     height: '100%', width: '100%' }}>
   <Bar data={
    
    data} width={
    
    Width} height={
    
    250} />
 </div>

这样子就解决问题了 ___ ^ $ ^ ___ nice

猜你喜欢

转载自blog.csdn.net/m0_46442996/article/details/109384690
今日推荐