Answer the question
In order to leave comments, you need to log in
How to pass an attribute to another component in Vue to use its value in your plugin?
There is a component. I am writing a plugin and I want to use the value from my attribute in someone else's component. It seems that I found in the Vue documentation that attributes can be passed, but either I didn’t understand what was meant, or I just can’t figure out how to get the value of this attribute in the plugin. I write like this
<v-text-field data-test="мой параметр"></v-text-field>
Answer the question
In order to leave comments, you need to log in
Thanks to all. I'm the idiot. The attribute was written in one component, and was looking for its value in another :(
If you write as in the example above
then this.$attrs component will have the attribute this.$attrs['data-test']="my parameter"
You will not be able to transfer your props to the component that you have connected to the project as an npm package, because you do not have this component in the project itself, it lies in node_modules. If you want to add your own properties or logic to the component, copy the entire component from node_modules and transfer it to your components folder, and only then can you edit it and then use it.
Then plug it in and use
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question