I am attempting to create a computed class in vue.js 2.0 using the following syntax:
<li :class="'str1' calcStarClass(1, p.rtg)"> </li>
In my methods section, I have the following:
methods: {
calcStarClass(starNum, rating) {
switch (starNum) {
case 1:
switch (rating) {
case (rating == 0):
return "str"
break;
case (0 < rating < 1):
return "strh"
break;
case (rating >= 1):
return "strf"
break;
default:
return "strf"
}
break;
case 2: ...
However, I encounter the following error message:
Raw expression: :class="'str1' calcStarClass(1, p.rtn)"
When I try
<li v-bind:class="'str1' calcStarClass(1, p.rtg)">
instead, I get this error:
invalid expression: Unexpected identifier in
'str1' calcStarClass(1, p.rtg)
Raw expression: v-bind:class="'str1' calcStarClass(1, p.rtg)"
I would like some help understanding what is causing this error and how I can resolve it.