最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why am I receiving invalid expression in my vue.js template? - Stack Overflow

programmeradmin7浏览0评论

I am receiving this error in my vue single file ponent:

  Errors piling template:

  invalid expression: Unexpected token { in

    {{ jobs[0].build_link }}

  Raw expression: v-bind:href="{{ jobs[0].build_link }}"

The full line is:

 <td :style=tdStyle><a v-bind:href="{{ jobs[0].build_link }}">{{ jobs[0].build_link }}</a></td>

jobs is defined in the data method of my ponent and i can console.log this data without issue.

Also not sure why, but this line works fine with an inline-template vue.js script but throws this error after converting over to a single page ponent.

I am receiving this error in my vue single file ponent:

  Errors piling template:

  invalid expression: Unexpected token { in

    {{ jobs[0].build_link }}

  Raw expression: v-bind:href="{{ jobs[0].build_link }}"

The full line is:

 <td :style=tdStyle><a v-bind:href="{{ jobs[0].build_link }}">{{ jobs[0].build_link }}</a></td>

jobs is defined in the data method of my ponent and i can console.log this data without issue.

Also not sure why, but this line works fine with an inline-template vue.js script but throws this error after converting over to a single page ponent.

Share Improve this question asked Jun 14, 2019 at 21:08 daviddavid 6,83517 gold badges58 silver badges98 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 5

I think you have a syntax problem. Please try without curly braces. for ex:

<td :style=tdStyle><a v-bind:href="jobs[0].build_link">{{ jobs[0].build_link }}</a></td>

Hope it works..

Removing the curly braces is correct in this case because the v-bind syntax is going to evaluate the expression, but double curly braces will also pre-evaluate it to a string so you end up trying to evaluate a string. So you essentially end up with something like v-bind:href="https://google.", but "https://google." is not a variable or expression. Make sense?

发布评论

评论列表(0)

  1. 暂无评论