Skip to content

官方示例 node/tool#editable 如何在新增文字后为其添加背景色?addTools 时 markup 的 attrs 不生效。 #3796

Answered by cnyballk
hylerrix asked this question in Q&A
Discussion options

You must be logged in to vote

可以试试用监听的方式改 比如

    graph.on('edge:labels:added', (e) => {
      e.added[0].attrs = {
        label: {
          ...e.added[0].attrs.label,
          fontSize: 34,
          fill: '#fff',
        },
        rect: {
          fill: '#000',
        },
      }
    })

编辑的时候可以

  edge.addTools({
    name:'edge-editor',
    args: {
      event: e,
      attrs: {
       fontSize: 34,
       color: '#fff',
       backgroundColor: '#000',
      },
    },
  })

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@cnyballk
Comment options

@hylerrix
Comment options

Answer selected by hylerrix
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants