0
我有一個簡單的聚合物畫布對象是這樣的:如何火attributeChanged,功能高分子
<polymer-element name="canvas-diagram" attributes="type width height json">
<template>
<div id="canvasField">
Typ: {{type}}, Width:<input value="{{width}}">, Height:{{height}}, json:{{json}}
<div id="canvasContainer">
<canvas id="canvasObj" width="{{width}}" height="{{height}}"></canvas>
</div>
</div>
</template>
<script>
function getMaxOfArray(numArray) {
return Math.max.apply(null, numArray);
}
Polymer("canvas-diagram",{
type: "bar",
width: "300",
height: "200",
ready: function() {
console.log("this.ready()");
this.writeDiagram();
},
attributeChanged: function(attrName, oldVal, newVal) {
console.log("this.attributeChanged()");
console.log(attrName, 'old: ' + oldVal, 'new:', newVal);
this.writeDiagram();
},
writeDiagram : function(){
[...]
},
json: {
data:[
{"name":"Texts","value":"150"},
{"name":"Videos","value":"50"},
{"name":"Audio","value":"30"},
{"name":"Test","value":"20"},
{"name":"Test","value":"20"},
{"name":"Test","value":"20"}
]}
});
</script>
</polymer-element>
但是當我canhage手動屬性的attributeChanged()函數犯規火。我究竟做錯了什麼?我敢打賭,綁定輸入threre。當我從canvas-diagram-Element中更改Attricute時,更改它也不會觸發Function。
這也行不通。我有 canvas-diagram> 當我改變其中一些屬性時,標籤和函數會觸發。 –
你想檢查變化的屬性是什麼? –
其中每一個。例如width屬性。然後我想要放棄一切。 –