React 开发踩坑

2019-10-15  本文已影响0人  yxz247

TypeError: instance.render is not a function

class RightSelectView extends Component {
    render() {
        return (
            <div className="ContentViewStyle">

            </div>
        );
    }
}

在用继承React.Component的方式生成一个组建的时候,如果没有生成render()系统会报错
TypeError: instance.render is not a function

在React使用img标签的时候不能直接使用src填写路径

方法一

import imgURL from 'photo.png';
<img src={imgURL } />

方法二

<img src={require('./../images/photo.png')} />

reaquire后跟路径是字符串不能为变量。

上一篇 下一篇

猜你喜欢

热点阅读