这里的关键词是
adjacent
. 所以你需要把
get
set
对于相邻的同一个属性:
class BinaryExpressionItem extends KKWebComponent implements KKBinaryExpressionItem {
public static TAG: string = `${CONSTANTS.TAG_PREFIX}-binary-expression-tem`;
private readonly expression: HTMLElement = <HTMLElement>this.shadowRoot.querySelector('var');
private readonly score: HTMLElement = <HTMLElement>this.shadowRoot.querySelector('mark');
constructor() {
super(template);
}
get expressionValue(): string { // The ones for expressionValue
return this.expression.textContent ?? ''; // The ones for expressionValue
} // The ones for expressionValue
// The ones for expressionValue
set expressionValue(value: string) { // The ones for expressionValue
this.expression.textContent = value; // The ones for expressionValue
} // The ones for expressionValue
get scoreValue(): string { // The ones for scoreValue
return this.score.textContent ?? ''; // The ones for scoreValue
} // The ones for scoreValue
// The ones for scoreValue
set scoreValue(value: string) { // The ones for scoreValue
this.score.textContent = value; // The ones for scoreValue
} // The ones for scoreValue
}
我总是先列出getter,然后再列出setter,但我认为ESLint不在乎,只要属性的两个部分相邻即可。