React 报错与解决方法

报错信息
Super expression must either be null or a function, not undefined

class Fruit extends React.component{
    
    
    render(){
    
    
        return <div>
            <Data name="orange"/>
            <Data name="apple"/>
            <Data name="watermelon"/>
        </div>
    }
}
const elem = <Fruit/>
ReactDOM.render(
    elem,
    document.getElementById("area")
)

很显然是继承的时候出现的问题 后来发现是component 的C没大写 组件没有继承到React.Component 如果遇到这种情况 可以看看 自己有没有拼写错误

报错信息
The tag xxxxxx is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.

报错原因是 封装组件时没有按照react的规范 react 没有识别出这是一个组件 本人出现这种错误是因为组件名开头没有大写

报错信息
Unknown DOM property class. Did you mean className?

检查一下标签 有没className 写成class

报错信息
Could not find a required file.
Name: index.js.js
这边 我在配置对页面应用

path里我是这样写的

  appIndexJs: resolveModule(resolveApp, 'src/index.js'),

后来发现脚手架他会帮你补充后缀 所以他找入口文件的时候会找index.js.js 自然 我项目里不会有这个文件

解决方法:把后缀的.js去掉

猜你喜欢

转载自blog.csdn.net/weixin_38987500/article/details/106792331