[Vuejs]-Why Eslint add a space automatically for object property name with hyphen?

3👍

You need to use square bracket syntax to access property names containing hyphens. Otherwise it will be treated as a minus operator.

<h2>{{ hero.biography['full-name'] }}</h2>

The normal rules for JavaScript property names apply within Vue template expressions. If the property name is a valid identifier you can use dot notation. Roughly speaking, that means it can contain alphanumerics, underscores and $. For other characters you need to use square brackets.

Leave a comment