I want to pass TailwindCSS pseudo-classes to a child component. However, I get an error message (Parsing error. Unexpected token :...).
Here is my code:
<cartImage :images="p.images" :classNames="hover:grow hover:shadow-lg" />
CodePudding user response:
It seems you just need to pass a static value to the classNames
prop. So you only need to remove the colon like this:
<cartImage :images="p.images" classNames="hover:grow hover:shadow-lg" />
CodePudding user response:
When you do this :
:classNames="hover:grow hover:shadow-lg"
it will think of hover:grow hover:shadow-lg
as a valid statement or variable - which will fail at this point.
If you want to pass a String
you have 2 Options :
Either with a static prop
classNames="hover:grow hover:shadow-lg"
Or you wrap the input inside 2 single quotes '...'
:
:classNames="'hover:grow hover:shadow-lg'"