B
B
BonBon Slick2020-06-01 05:41:02
typescript
BonBon Slick, 2020-06-01 05:41:02

VuexModule class private field?

export default class LayoutDefault extends Vue {
    @user.State
    public name!: string // test
    @user.Getter
    public nameUpperCase!: string // test

for such a module, although the field is private to exclude direct access via State
@Module({namespaced: true})
export default class User extends VuexModule {
    private name: string = 'test';

    public get nameUpperCase(): string {
        return this.name


Both options are available in the template, can you directly privatize state?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-06-01
@BonBonSlick

private guarantees you only that you cannot use it directly in the code. What is heaped up there through decorators and reflection is no longer controlled.
Even more so in a template.
Perhaps when the real hello class properties from es2020 arrive, it will be what you want. But by that time there will already be vue 3 where the classes were abandoned.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question