VM1158:32 Uncaught SyntaxError: Unexpected token ‘}‘

created at 03-19-2022 views: 5


Directly using cnd to introduce vue as a project, a small bug encountered

First, the error message is as follow:

VM1158:32 Uncaught SyntaxError: Unexpected token ‘}‘

This error message is still obvious:

<img :src="`images/${image}`/">

However, our actual writing code is:

<img :src=`images/${image}`/>

It mainly uses template strings to splicing the contents of the v-for loop. After thinking about it, there is no problem. How could this be a problem? The brackets are also correct.

reason and solution

Later, after I inadvertently hit a space, the world was restored

<img :src=`images/${image}` />

Note the space between the back slash template string, and the /> , resolved this problem.

Guessing should be dictated by grammar.

created at:03-19-2022
edited at: 03-19-2022: