我将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