声明字段 public vs private with public accessor lwc child component

Declaring field public vs private with public accessor lwc child component

我需要将参数从父组件传递给 lwc 中的子组件。将字段设置为 public 与使用 public 访问器私有字段之间有区别吗?

// Private field with public getter
import { LightningElement, api, track } from 'lwc';

export default class TodoItem extends LightningElement {
    @track 
    _itemName = 'New Item'; 

    @api
    get itemName() {
        return this._itemName;
    }

    set itemName(value) {
        this._itemName = value;
    }
}

//Public accessor
import { LightningElement, api, track } from 'lwc';

export default class TodoItem extends LightningElement {
    @api 
    _itemName = 'New Item'; 
}

在 LWC 中推荐的是:

//Public accessor
import { LightningElement, api } from 'lwc';

export default class TodoItem extends LightningElement {
    @api 
    itemName = 'New Item'
}

P.S:轨道装饰器现在是 useless

Like all fields as of Spring ’20, they’re reactive