TypeError: instance.render is not a function 2022-01-28 23:39 98阅读 0赞 1、错误描述 ![watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly95b3VoYWlkb25nLmJsb2cuY3Nkbi5uZXQ_size_16_color_FFFFFF_t_70][] 2、错误原因 import React, {Component} from 'react'; import {render} from 'react-dom'; import Button from 'react-bootstrap/Button' class InputRead extends Component { constructor() { return { user: '' }; } inputChange(e) { this.setState({user:e.target.value}); } clearAndFocus() { this.setState({user:''},()=>{ this.refs.thisInput.focus(); }) } render() { return ( <div> <Button onClick={this.clearAndFocus.bind(this)}> 清空 </Button> <input ref="thisInput" value={this.state.user} onChange={this.inputChange.bind(this)}/> </div> ) } } export default InputRead; 构造函数中不能使用return语句,否则以为构造函数中需要添加render()方法 3、解决办法 import React, {Component} from 'react'; import {render} from 'react-dom'; import Button from 'react-bootstrap/Button' class InputRead extends Component { constructor(props) { //return { user: '' }; super(props); this.state = { user: '' }; } inputChange(e) { this.setState({user:e.target.value}); } clearAndFocus() { this.setState({user:''},()=>{ this.refs.thisInput.focus(); }) } render() { return ( <div> <Button onClick={this.clearAndFocus.bind(this)}> 清空 </Button> <input ref="thisInput" value={this.state.user} onChange={this.inputChange.bind(this)}/> </div> ) } } export default InputRead; [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly95b3VoYWlkb25nLmJsb2cuY3Nkbi5uZXQ_size_16_color_FFFFFF_t_70]: /images/20220128/06959ce8f098484991ea7e50e7d6440d.png 文章版权声明:注明蒲公英云原创文章,转载或复制请以超链接形式并注明出处。
相关 Syntax Error: TypeError: this.getOptions is not a function ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ub 港控/mmm°/ 2021年07月26日 09:43/ 0 赞/ 351 阅读
相关 Uncaught TypeError: form.render is not a function 引言:一直报这个错误,刚开始不知道哪里的问题,后来才明白原来是,引入的layui.js跟引入jquery的包产生了冲突。 把引入的js包注释掉就可以了,不会产生冲突了。 < 我会带着你远行/ 2021年09月23日 07:14/ 0 赞/ 110 阅读
相关 "TypeError: handler.call is not a function"问题 进入组件页面时,vue报错:Error in mounted hook: "TypeError: handler.call is not a function", ![157 梦里梦外;/ 2021年11月27日 06:48/ 0 赞/ 160 阅读
相关 TypeError: instance.render is not a function 1、错误描述 ![watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly95b3VoYWlkb25nLmJs 旧城等待,/ 2022年01月28日 23:39/ 0 赞/ 99 阅读
相关 TypeError: "_vm.onetopic is not a function" 解决方案 1、方法 onetopic要放在methods:\{\}里面 2、看看自己是不是多个\},导致方法在methods:\{\}外面了 ------------ 浅浅的花香味﹌/ 2022年02月01日 11:15/ 1 赞/ 141 阅读
相关 TypeError: db.collection is not a function 1、错误描述 F:\nodejs>node insertData.js (node:10028) DeprecationWarning: current UR 比眉伴天荒/ 2022年05月16日 08:11/ 0 赞/ 74 阅读
相关 TypeError:(0 ,jsdom.jsdom) is not a function 在使用`Enzyme`测试容器组件时,为了能使用`mount`方法递归渲染出所有`DOM`,不得不使用`JSDOM`在`Node.js中`模拟一个类似浏览器的环境。于是有了下面 朱雀/ 2022年05月25日 19:57/ 0 赞/ 83 阅读
相关 Uncaught TypeError: c(...).off is not a function(… layer.open({ title: 'test', content: 'hello layer' }) 运行上面的代码,能弹出对话框,但按确定对话框不消失. 控制 喜欢ヅ旅行/ 2022年05月29日 21:05/ 0 赞/ 68 阅读
相关 Uncaught TypeError: XXX.getTime is not a function 因为变量只是字符串,无法调用日期函数。 你应该解析它们以获得一个`Date`对象,对于该格式我总是使用以下函数: // parse a date in yyyy-m 淡淡的烟草味﹌/ 2022年09月27日 17:16/ 0 赞/ 80 阅读
相关 Vue TypeError: this.$confirm is not a function 错误 在使用element ui,采用局部引入时候,报错`TypeError: this.$confirm is not a function`。 ![在这里插入图片 Dear 丶/ 2022年12月23日 14:24/ 0 赞/ 55 阅读
还没有评论,来说两句吧...