javascript - 没有从反应js中的事件调用函数
问题描述
在这种情况下,当函数呈现元素onMouseUp
中发生类似事件时,getSingleCard
我想调用expandDiv
函数但控件没有进入函数,什么都没有发生。有人可以帮我解决这个问题吗?
class WikiArea extends Component
{
constructor(props)
{
super(props);
this.expandDiv = this.expandDiv.bind(this);
}
render()
{
if(this.props.result!=null)
console.log(this.props.result[1]);
var totalArray = this.props.result;
var y;
var self = this;
if(totalArray!=null)
{
return totalArray.map(this.getSingleCard,this);
}
else {
return <div></div>;
}
}
// onKeyPress ={event => this.onInputChange(event)
//console.log(event.currentTarget.id);this.viewMore.bind(this, attributeId)
getSingleCard(val)
{
console.log("syam");
console.log(self);
var x=val;
if(val!=null){
return (<div className="panel panel-default card-background" id={val["s.no"]} onMouseUp = {event => {this.expandDiv.bind(this);}}>
<p>{val["amt.pledged"]}</p>
<p>{val.blurb}</p>
</div>);
}
else{
return (<div></div>);
}
}
expandDiv(event){
console.log("Entering into the div");
}
};
解决方案
推荐阅读
- rxjs - 如何以更惯用的 rxjs 方式处理这些功能
- node.js - express.Router() 与 express 中的 express()
- jmeter - 如何通过 Jmeter JMS 点对点向 JMS 队列发送字节消息
- reactjs - React-Testing-Library(RTL):动画导致带有 React Pose 的 TypeError
- firebase - Firebase 部署正在部署我的源文件夹未加密
- jquery - AJAX 调用 .NET Core API 失败
- image - 如何在 Swift 4 中显示 UILabel html 内容、图像、视频
- html - 使用 XSLT 和 XPath 将 XML 数据文件解析为 HTML 表
- c# - 记住在列表中添加列表的语法
- javascript - 通过 AJAX 将 JS 多维数组发布到 PHP