reactjs - create-react-app 中的 CytoscapeJS 未触发 console.log
问题描述
我Cytoscape.js
用create-react-app
. 终端正在运行应用程序,但没有输出console.log
. 尤其是在handleClick
方法上。
import React, { Component } from 'react'
import Cs from 'cytoscape'
const { cyConfig, cyStyle } = require('./config/config')
class Graph extends Component {
componentDidMount () {
cyConfig.container = document.getElementById('cy')
this.cy = Cs(cyConfig)
}
handleClick () {
this.cy.on('tap', 'node', (e) => {
const node = e.target
console.log(node.id())
})
}
render() {
return (
<div
style={cyStyle}
id='cy'
onClick={ (e) => this.handleClick(e) }
/>
)
}
}
export default Graph
解决方案
推荐阅读
- java - 如何为在java中返回列表的restful服务编写测试用例
- android - 检测到 offroutelistener 时重新路由横幅指令
- authentication - Kafka:启用多种身份验证方法
- cassandra - Cassandra WRITE=ALL 和 READ=ONE 适用性
- pandas - 如何使用 txt 文件进行拼写校正
- html - 我怎样才能让我的两个盒子在同一行?
- java - 表列文本和值不完整可见?
- text - Flutter 文本显示问题
- r - 当我通过美学提供其价值时,无法使 geom_sf 线宽正常工作
- android - 为什么我在添加 OssLicensesMenuActivity 时出错