I'm looking to access attributes (fieldType
, value
) within a dynamic attribute (:class
)
<div fieldType="favoriteSports"
@click="update_favorite_sports"
value="Soccer"
:class="{selected: sportsForm[fieldType].indexOf(value) != -1 }">
Soccer
</div>
An error is displayed as follows:
Property or method "fieldType" is not found on the instance but referenced during render. Remember to declare reactive data properties in the data option.
It seems like fieldType needs to be defined as a data property.
How can this be accomplished, or is it considered an anti-pattern?