美文网首页
React 开发踩坑

React 开发踩坑

作者: yxz247 | 来源:发表于2019-10-15 11:38 被阅读0次

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后跟路径是字符串不能为变量。

相关文章

网友评论

      本文标题:React 开发踩坑

      本文链接:https://www.haomeiwen.com/subject/rmajmctx.html