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