我必须将它作为聚合物元素中的参数传递:
[
["id", "nome", "idade"],
[1, "matheus", 16],
[2, "cristian", 16],
[3, "pedro", 10],
[4, "henrique", 10]
]
如何在聚合物特性领域声明这个变量(矩阵)?
我如何声明我的元素:
<script>
Polymer({
is: "table-element",
properties: {
id: String,
matrixdata: Array
},
ready: function() {
document.getElementById(this.id).appendChild(criarTabela(this.matrixdata));
}
});
</script>
答案 0 :(得分:1)
我认为这应该有用
<my-comp matrix='[
["id", "nome", "idade"],
[1, "matheus", 16],
[2, "cristian", 16],
[3, "pedro", 10],
[4, "henrique", 10]
]'></my-comp>
如果matrix
属性的类型为Array
matrix: {
type: Array
}
另请参阅https://elements.polymer-project.org/elements/google-chart
中的rows
或data
示例