when googling about vue mixins, I've surprised that have so many guide about this topic, but all of demo code used single file template (or vue project template...). So how to use vue mixins in normal javascript file. My case like this:
First, I used php-yii2 template to develop my website (included botth backend and frontend). In frontend, I added vue.js file into my project to use vue features. Sometimes, have some generic function that can be re-use so I think vue mixins can resolve these case. In my approach, I will create a seperate .js file to declare mixins object, then other vue object (in other .js files) can re-use that mixins object method.
Do you have any ideas for my case. Thank you so much.
how to use mixins in normal javascrip file (not single file template)
460 Views Asked by GIANGPZO At
1
Your mixin definition (
some-mixin.js
):Inside a component (
your-component.js
) you can now tell the component that you want to consume this mixin:and then you can just use whatever you defined in the mixin in your template:
and also code: