Reputation: 527
According to the recommendation of the Vue directive, it is recommended to use the directive in general cases for many components. How can I then correctly remake for example such a directive, which is used only once in the one component.
dropped(el, binding, vnode) {
if (vnode.context.isDropped) {
el.style.height =
el.firstChild.scrollHeight+
"px";
} else {
el.style.height = 0;
}
},
Upvotes: 0
Views: 53
Reputation: 1025
Is it correct to use one directive once in one component?
You would need to define correct in regards to what, but no it does not pose a problem. You can use a directive as much or little as you like.
However since your asking about code style, if your directive is going to be used only on one component, why not put it directly in the component's code?
Upvotes: 1