Согласно этому источнику, вы должны вызвать renderView для инициализации представления:
// index.js
import Cytoscape from './Cytoscape.vue';
export default Cytoscape;
/* cssFile.css */
#cyto {
height: 100%;
display: block;
border: 1px solid blue;
}
<!-- AppVue.js -->
<template>
<div class="cytoscape"></div>
</template>
<style>
</style>
<script>
import cytoscape from 'cytoscape';
export default {
name: "HelloWorld",
data: function() {
return {
cy: null
};
},
props: {
msg: String
},
methods: {
renderView: function(newElements) {
// the only reliable way to do this is to recreate the view
let cy = cytoscape({
container: this.$refs.cyto,
elements: [
// list of graph elements to start with
{
// node a
data: {
id: "a"
}
},
{
// node b
data: {
id: "b"
}
},
{
// edge ab
data: {
id: "ab",
source: "a",
target: "b"
}
}
],
style: [
// the stylesheet for the graph
{
selector: "node",
style: {
"background-color": "#666",
label: "data(id)"
}
},
{
selector: "edge",
style: {
width: 3,
"line-color": "#ccc",
"target-arrow-color": "#ccc",
"target-arrow-shape": "triangle"
}
}
],
layout: {
name: "grid",
rows: 1
}
});
}
},
mounted: function() {
this.$emit('created', this);
}
}
</script>