比方说,我们正在尝试使用网络api从列表中删除一个项目。我们使用参数-item和onRemove创建了一个名为remove-item的子组件。单击某个项目时,我们想触发父代码的回调函数。根据代码,删除该项目后不会调用onRemove。有人可以帮助我们找出错误并为我们提供插图的正确解决方案。
remove.component.js
-------------------
this.RemoveItem = function (index) {
var promise = productList.removeItem(parseInt(this.id));
promise.then(function (response) {
console.log("An item has been deleted");
this.items=response.data;
},function (error) {
console.log("An error has occurred while deleting the item:",this.id);
});
this.onRemove({
$index: this.items
});
}