假设我有两个组成部分。 function copyCells(){
var thisSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var SourceSheet = thisSpreadsheet.getSheetByName("test");
var SourceRange = thisSpreadsheet.getRange("C2:C102");
var SourceValues = SourceRange.getValues();
var destinationSheet = thisSpreadsheet.getSheetByName("test");
var destinationRange = destinationSheet.getRange("D2:D102");
var destinationValues = destinationRange.getValues();
for (var i = 0; i < SourceValues.length; i++)
destinationValues[i][0] = parseFloat(destinationValues[i][0]) + parseFloat(SourceValues[i][0])
destinationRange.setValues(destinationValues);
}
和ParentComponent
。 ChildComponent
具有ParentComponent
属性,并与age
进行双向绑定。
ChildComponent
import { Component } from "@angular/core"
@Component({
selector: "app-parent",
template: "<app-child [(age)]="age"></app-child>"
})
export class ParentComponent {
age = 25
}
每当import { Component, Input, Output, EventEmitter } from "@angular/core"
@Component({
selector: "app-child",
template: "<p>{{ age }}</p>"
})
export class ChildComponent {
@Input()
age = 0
@Output()
ageChange = new EventEmitter()
}
中age
的值发生变化时,Angular会将更改传播到ParentComponent
。并且当ChildComponent
发出ChildComponent
事件时,更改将同步回到ageChange
。当后者发生时,ParentComponent
会检测到其属性已更改,并将更改传播给子级。但是孩子已经有了新的价值!
这似乎效率低下。有没有办法防止这种“假”更新?我是否缺少某些东西,或者这是Angular的工作方式?