当我从 jquery 选择器调用 vuejs 函数时,它不会触发。我已经在 vue 组件中集成了 d3-dagre 图表。当我为节点设置点击操作时,它不会触发 vuejs 方法。在下面的 getJobid() 没有触发。找到下面的vue组件代码,最后也报错。
Vue组件:
export default {
name: 'dagView',
created () {
console.log('test2')
},
mounted () {
var g = new dagreD3.graphlib.Graph().setGraph({})
// Create the renderer
var render = new dagreD3.render()
// Set up an SVG group so that we can translate the final graph.
var svg = d3.select("svg"),
inner = svg.append("g")
// Run the renderer. This is what draws the final graph.
render(inner, g)
inner.selectAll("g.node")
.on("click", function(v) {
console.log("Nodes --> "+ v + " -- "+ g.node(v).label)
this.nodeId = g.node(v).label
console.log("Node id -- "+ this.nodeId)
this.getJobid()
})
},
methods: {
getJobid: function() {
console.log('Received NodeId')
}
}
}
错误:
Uncaught TypeError: this.getJobid is not a function
at SVGGElement.eval (DAG.vue?2ccc:180)
at SVGGElement.__onclick (d3.v3.min.js:1)