Javascript 未删除删除元素的聚合物
使用Polymer Stater工具包,我创建了两个自定义元素:Javascript 未删除删除元素的聚合物,javascript,data-binding,polymer,polymer-1.0,Javascript,Data Binding,Polymer,Polymer 1.0,使用Polymer Stater工具包,我创建了两个自定义元素: flow-list.html(此处声明为flowElementArray) flow-element.html(这里定义了delete函数) 在app.js文件中,我还定义了一个addElement函数 我可以向flowElementArray添加元素,并显示它们 但是,当我从flowElementArray中删除元素时,它们仍然显示 下面是我如何得到以下结果的: 应用程序启动(预加载2项) 我删除一项(该项保留在屏幕上) 我
- flow-list.html(此处声明为flowElementArray)
- flow-element.html(这里定义了delete函数)
- GitHub回购:
- GitHub页面:
app.storageLoaded = function() {
if (this.$.s1.value === '' || this.$.s2.value === '') {
window.alert('One field is Empty!');
return;
}
this.$.flowListID.push('flowDictionnary',
{
first: this.$.s1.value,
last: this.$.s2.value
});
};
我如何删除:
removeItem: function() {
var counter = 0;
while (counter < this.dict.length) {
var item = this.dict[counter];
if (item.first === this.name) {
this.dict.splice(counter, 1);
} else {
counter++;
}
}
}
removietem:function(){
var计数器=0;
while(计数器
在Polymer中对数组属性执行操作时,需要在操作后使用this.push('myArrayProperty',item)
,this.splice('myArrayProperty',0,1)
或调用this.notifyPath('myArrayProperty')
removeItem: function() {
var counter = 0;
while (counter < this.dict.length) {
var item = this.dict[counter];
if (item.first === this.name) {
// this.dict.splice(counter, 1);
this.splice('dict', counter, 1);
} else {
counter++;
}
}
}
removietem:function(){
var计数器=0;
while(计数器
在Polymer中对数组属性执行操作时,需要在操作后使用this.push('myArrayProperty',item)
,this.splice('myArrayProperty',0,1)
或调用this.notifyPath('myArrayProperty')
removeItem: function() {
var counter = 0;
while (counter < this.dict.length) {
var item = this.dict[counter];
if (item.first === this.name) {
// this.dict.splice(counter, 1);
this.splice('dict', counter, 1);
} else {
counter++;
}
}
}
removietem:function(){
var计数器=0;
while(计数器
向我们展示代码,以便我们可以帮助您。如果你在jsbin中做这件事,那将是完美的。我没有成功地从在这种网站(jsbin、codepen、plunker)上工作的Polymer中创建一个简单的自定义元素,因此我决定将我的工作上传到GitHub并创建一个GitHub。我知道它没有这些网站好。至少它的工作原理和我的电脑完全一样。没有人对调查整个项目感兴趣。请提供一个最小的示例,允许重现问题(另请参阅),您需要阅读以下内容:。听起来您没有使用this.push()
或this.splice()
从数组中添加/删除项。我添加了如何添加和删除元素。我正在开发一个JSFIDLE。向我们展示代码,以便我们可以帮助您。如果你在jsbin中做这件事,那将是完美的。我没有成功地从在这种网站(jsbin、codepen、plunker)上工作的Polymer中创建一个简单的自定义元素,因此我决定将我的工作上传到GitHub并创建一个GitHub。我知道它没有这些网站好。至少它的工作原理和我的电脑完全一样。没有人对调查整个项目感兴趣。请提供一个最小的示例,允许重现问题(另请参阅),您需要阅读以下内容:。听起来您没有使用this.push()
或this.splice()
从数组中添加/删除项。我添加了如何添加和删除元素。我正在一个jsfiddle上工作。