js中的链接元素在鼠标移到它们上面时会消失

link elements in joint.js dissapear when mousing over them.

本文关键字:消失 链接 元素 鼠标 js      更新时间:2023-09-26

我正在使用FSA插件在joint.js中构建一个FSA应用程序。然而,当我把鼠标移到链接上时,它们就消失了。

这是相关的javascript代码:
function link(source, target, label, maxsize) {
  var vertices = []
  if (source.id == target.id) {
       vertices = [{ x:source.attributes.position.x+10*maxsize, y:source.attributes.position.y-40 }, { x:source.attributes.position.x+10*maxsize, y:source.attributes.position.y+40 }]; 
  }   
  var w = parseInt(label,10);
  if (source.id == init.id || target.id == term.id) 
      label = ""; 
  var cell = new joint.shapes.fsa.Arrow({
      source: { id: source.id },
      target: { id: target.id },
       labels: [{ position: .5, attrs: { text: { text: label || '', 'font-weight': 'bold' } } }], 
      vertices: vertices || []
  }); 
  cell.weight = w;
  return cell;

}

如何解决这个问题?

看来你一定是得到一些错误的浏览器控制台。你能把它贴在这里吗?它看起来像别的东西是错误的,而不是你发布的代码。但是,我看到你直接进入了source.attributes.position.x。注意,这不是公共API的一部分。你应该使用source.get('position').x.