這是我的聚合物元件:如何在聚合物元素中使用細胞色素?
<link rel="import" href="../polymer/polymer.html">
<script src="bower_components/cytoscape/dist/cytoscape.js"></script>
<dom-module id="dependency-graph">
<template>
<style>
#surface {
width: 200px;
height: 200px;
}
</style>
<div id="surface"></div>
</template>
<script>
Polymer({
is: 'dependency-graph',
ready: function() {
var surface = this.$.surface;
var cy = cytoscape({
container: surface
});
...
運行,這將引發Cytoscape中
return (_p.sizeCache = _p.sizeCache || (container ? (function(){
var rect = container.getBoundingClientRect();
var style = window.getComputedStyle(container);
var val = function(name){ return parseFloat(style.getPropertyValue(name)); };
return {
width: rect.width - val('padding-left') - val('padding-right') - val('border-left-width') - val('border-right-width'),
height: rect.height - val('padding-top') - val('padding-bottom') - val('border-top-width') - val('border-bottom-width')
};
因爲style.getPropertyValue
回報""
異常。如果我使用document.body
作爲容器,它將返回一個數字和cytoscape作品。我做錯了什麼,我該如何解決?
我發現有關類似問題的文章,但我沒有得到它(或它不工作?):webcomponentsjs is not compatible with third-party scripts that use window.getComputedStyle