我正在尝试使用vue和axios加载cytoscape图。无论如何不能配置cytoscape,所以我首先尝试与axios和vue只。范围仍然存在问题,但我不知道在哪里?我应该改变什么?如何正确设置vue和axios。Axios无法将数据加载到vue
编辑
所以设置this.nodes后,我想提请在cytoscape.js一个grapg,但我总是得到错误:
-The样式属性text-outline-color:
无效
- 不要将映射分配给没有相应数据的元素(例如ele 6b899f09-359e-424d-9461-d71c8c3fcd3b
对于属性text-outline-color
与数据字段faveColor
);尝试[faveColor]
选择限制范围与faveColor
元素定义
-Uncaught类型错误:空
不能设置属性“映射”我相信这是阵列的问题,但我无法弄清楚如何设置阵列正确,这可以工作。
这里是代码:
draw: function(){
this.cy = cytoscape({
container: document.getElementById('cy'),
layout: {
name: this.main_layout,
padding: 10
},
style: cytoscape.stylesheet()
.selector('node')
.css({
'shape': 'data(faveShape)',
'width': 'mapData(weight, 40, 80, 20, 60)',
'content': 'data(name)',
'text-valign': 'center',
'text-outline-width': 2,
'text-outline-color': 'data(faveColor)',
'background-color': 'data(faveColor)',
'color': '#fff'
})
.selector(':selected')
.css({
'border-width': 3,
'border-color': '#333'
})
.selector('edge')
.css({
'curve-style': 'bezier',
'opacity': 0.666,
'width': 'mapData(strength, 70, 100, 2, 6)',
'target-arrow-shape': 'triangle',
'source-arrow-shape': 'circle',
'line-color': 'data(faveColor)',
'source-arrow-color': 'data(faveColor)',
'target-arrow-color': 'data(faveColor)'
})
.selector('edge.questionable')
.css({
'line-style': 'dotted',
'target-arrow-shape': 'diamond'
})
.selector('.faded')
.css({
'opacity': 0.25,
'text-opacity': 0
}),
elements: {
nodes: this.nodes
},
ready: function(){
window.cy = this;
}
});
如果我这样做,在控制台中我仍然得到空。怎么了?这里是jsbin [link] https://jsbin.com/piwusuyici/edit?js我正在使用npm。 – Tim
jsbin不起作用。你试图得到的网址可能是错误的。你没有一个范围问题。 – Reiner
这只是代码。但为什么我仍然在console.log(this.projekt)中变为空? – Tim