4

Code

 <div class="flex justify-center">
            <vs-chip v-if="current" class="text-base w-24" :color="color">
              {{
                getPercentage > 0 && getPercentage < 3
                  ? "Neutral"
                  : getPercentage > 3 && current < average
                  ? "Buy"
                  : "Sell"
              }}
            </vs-chip>
          </div>

How can I fix this parsing error in vue ?

Is there a way to solve this without disabling the eslint rule ? error screenshot

Abdullah Ch
  • 1,678
  • 1
  • 13
  • 31

3 Answers3

2

In my case by adding the following under the rules of .eslintrc.js worked:

"vue/no-parsing-error": [
    "error", 
    {
        "invalid-first-character-of-tag-name": false,
    }
],

PS: you may need to stop the server and run npm run lint for the rule to be applied

Pontios
  • 2,377
  • 27
  • 32
0

Other solutions if you do not want to update eslint:

Using v-text directive:

<div class="flex justify-center">
  <vs-chip v-if="current" class="text-base w-24" :color="color" v-text="
    
      getPercentage > 0 && getPercentage < 3
          ? 'Neutral'
  : getPercentage > 3 && current < average
  ? 'Buy'
  : 'Sell'
  ">
  </vs-chip>
</div>

Or using &lt replace <, and &gt replace >:

<div class="flex justify-center">
        <vs-chip v-if="current" class="text-base w-24" :color="color">
          {{
            getPercentage &gt 0 && getPercentage &lt 3
              ? "Neutral"
              : getPercentage &gt 3 && current &lt average
              ? "Buy"
              : "Sell"
          }}
        </vs-chip>
      </div>
huan feng
  • 7,307
  • 2
  • 32
  • 56
0

This is probably better solved with a computed property instead of a nested ternary (I'm assuming that getPercentage, current and average are either data or props, hence adding this)

computed: {
  myLabel() {
    if (this.getPercentage > 0 && this.getPercentage < 3) {
      return "Neutral"
    } else if (this.getPercentage > 3 && this.current < this.average) {
      return "Buy"
    } else {
      return "Sell"
    }
  }
}

In component

<div class="flex justify-center">
  <vs-chip v-if="current" class="text-base w-24" :color="color">
    {{myLabel}}
  </vs-chip>
</div>
Kieran101
  • 565
  • 5
  • 18