1

I am using an API(MySportsFeeds.com) that returns an object with property names that contain the characters # and @ in them. I get a Vue error message:

"- invalid expression: illegal character in _s(item.stats.Wins.@abbreviations) Raw expression: {{ item.stats.Wins.@abbreviations}}

when trying to access these object properties.

Here is an example Vue template code snippet:

 <div v-for="value in props_league_standings">
            <p class="box-score-team" v-for="item in value.teamentry"> 
               <span class=box-score-team>{{ item.stats.Wins.@abbreviations}}</span>
            </p>
 </div>

Does anyone know how I can access these properties with special characters in their names in the Vue template. Thanks in advance

Alan
  • 1,067
  • 1
  • 23
  • 37
  • 1
    like `{{ item.stats.Wins['@abbreviations']}}`? – Sphinx Sep 10 '18 at 21:28
  • Wins is not an array. it is an object with a property of @abbreviation – Alan Sep 10 '18 at 21:33
  • Possible duplicate of [How to access object properties containing special characters?](https://stackoverflow.com/questions/12953704/how-to-access-object-properties-containing-special-characters) – Sphinx Sep 10 '18 at 21:35
  • Im sorry I misunderstood you. Good idea using bracket notation but unfortunately get same error message. – Alan Sep 10 '18 at 21:38
  • and to stress it is Vue throwing warning: [Vue warn]: Error compiling template: – Alan Sep 10 '18 at 21:41
  • if so, it should be something else caused the problem. check [this fiddle](https://jsfiddle.net/gy73tsk2/) which works for one property name with special characters. – Sphinx Sep 10 '18 at 21:42
  • my fault I forgot the parenthesis in bracket notation. It works ok now. good pickup I forgot totally about bracket notation being used. Saved me alotta grief. – Alan Sep 10 '18 at 22:00

0 Answers0