B
B
BonBon Slick2021-07-29 00:35:22
typescript
BonBon Slick, 2021-07-29 00:35:22

Passing a parameter to a mixin?

Because wu has the best support for TS, it is not yet clear to me how to pass the parameter at the compilation stage.
If you pass a parameter after the mixin is initialized, then there will be errors. The mixin needs a parameter to work. $emit and store won't help here.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BonBon Slick, 2021-08-25
@BonBonSlick

There is no adequate solution, passing dynamic parameters to Vue 2 + TS is conditionally impossible.

@Template
@Component<AccountSettingsForm>(
    {
        components: {},
        mixins:     [
            testMixin(this.namespace)
        ],

export default class AccountSettingsForm extends mixins(Mixin_1(this.param)) {...}

All this is inoperable because this does not yet exist at the time of initialization.
The only option I came up with was to throw out TS or use it for some components which makes it useless or of little use.
This means, long live shitcode and thousands of lines of duplicates that need to be maintained! Changed 1 character in module root? Great, you need to go through all the components and fix them, when there are tens and hundreds of lines where the action \ getter is called, autocorrect by name does not give a 100% guarantee that everything will be replaced

A
Aetae, 2021-08-02
@Aetae

You're clearly misusing mixins. Think of mixins as multiple inheritance. You cannot dynamically change the class from which it is inherited depending on the parameters of the instance, no?
So here you have to come up with something different. Most likely you just need to reverse the approach - make a mixin what you have is a component, and components (different) - what you want to make a mixin.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question