通过数据数组链接背景图像 [英] Background image link by data array

查看:70
本文介绍了通过数据数组链接背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在cytoscape.js中出现此错误:

I get this error in cytoscape.js:

不要将映射分配给没有相应数据的元素(例如ele p (属性 background-image 的数据字段为 linkImagem );请尝试 [ linkImagem] 选择器,将范围限制为定义了 linkImagem 的元素

"Do not assign mappings to elements without corresponding data (e.g. ele p for property background-image with data field linkImagem); try a [linkImagem] selector to limit scope to elements with linkImagem defined"

查找数据数组:

{ data: { id: 'atr1', classificacao : '1', backgroundColor : '#F79646', nomeAtributo : 'Bancos desconfortáveis', angulo : '0', valign : 'top', halign : 'right', linkImagem : 'http://www.fec.unicamp.br/~confterm/imagens/background/nodes/8.png' }, position: { x:220, y: 300 }, selected: false, selectable: false, locked: false, grabbable: false }

查看脚本样式选项:

.selector('node')
          .css({
            'label': 'data(nomeAtributo)',
            'text-valign': 'data(valign)',
        'text-halign': 'data(halign)',
            'color' : '#000',
            'font-size': '11px',
            'background-fit': 'fit',
            'background-color': 'data(backgroundColor)',
            'background-image': 'data(linkImagem)',
          })

我该如何解决?

推荐答案

您在错误消息中。如果您不打算为每个匹配的元素定义数据,要么不使用映射器,要么调整选择器,使其仅匹配定义了数据的元素。

The solution is given to you in the error message. Either don't use mappers if you're not going to define the data for each matching element, or adjust your selectors so that they only match elements with the data defined.

这篇关于通过数据数组链接背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆