Polymer 1.0 在聚合物函数中添加变量
Polymer 1.0 Adding variables in a polymer function
我不确定这是一个错误还是我做错了什么。
我有 6 个房产
(function () {
Polymer({
is: 'claim-type',
properties: {
foo: {
type: Number,
value: false,
observer: 'add'
},
bar: {
type: Number,
value: false,
observer: 'add'
},
....
等等....
每个都链接到
当一个改变时它触发观察者'add'
add: function () {
this.ray = this.bar + this.foo + this.etc;
}
说 foo = 1 和 bar = 2 等 = 3
结果将等于 123 而不是 6?
我做错了什么?
编辑:将代码从布尔类型更改为数字
Polymer 似乎将数字视为字符串。这可能是因为它正在使用 paper-input
需要在变量前加上+号才能转换成数字
add: function () {
this.ray = +this.bar + +this.foo + +this.etc;
}
我不确定这是一个错误还是我做错了什么。
我有 6 个房产
(function () {
Polymer({
is: 'claim-type',
properties: {
foo: {
type: Number,
value: false,
observer: 'add'
},
bar: {
type: Number,
value: false,
observer: 'add'
},
....
等等....
每个都链接到
当一个改变时它触发观察者'add'
add: function () {
this.ray = this.bar + this.foo + this.etc;
}
说 foo = 1 和 bar = 2 等 = 3
结果将等于 123 而不是 6?
我做错了什么?
编辑:将代码从布尔类型更改为数字
Polymer 似乎将数字视为字符串。这可能是因为它正在使用 paper-input
需要在变量前加上+号才能转换成数字
add: function () {
this.ray = +this.bar + +this.foo + +this.etc;
}