Vuejs2 当真正需要字符串插值时,如何在vue模板中绑定变量

Vuejs2 当真正需要字符串插值时,如何在vue模板中绑定变量,vuejs2,Vuejs2,本周末刚刚学习Vue2 我正在尝试这样做: <a href='/arc/locations/{{location.id}}/edit'>edit here</a> 但得到的错误是: - href="/arc/locations/{{location.id}}/edit": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For e

本周末刚刚学习Vue2

我正在尝试这样做:

<a href='/arc/locations/{{location.id}}/edit'>edit here</a>

但得到的错误是:

- href="/arc/locations/{{location.id}}/edit": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">.
-href=“/arc/locations/{{location.id}}}/edit”:属性内部的插值已被删除。改用v-bind或冒号速记。例如,使用而不是。
这有点让人困惑——我试图写出一个不会改变的字符串,它似乎想要创建一个绑定元素。我如何在url中将其作为字符串输出?如果我不能这样做,我如何使用Vue将其插入url


总的来说,我喜欢它,但也有一些预期的缺陷

如警告所述,您应该使用
v-bind
(仅用于冒号
):


正如警告所述,您应该使用
v-bind
(仅用于冒号
):



thx-我通常只使用jQuery作为前端so和Vue的新手。我有点担心不必要的绑定和性能。该应用程序将在页面上显示数百个项目。在这种情况下,我应该限制绑定吗?或者,从性能角度看,这不应该是一个问题。我知道有点推测性,但我不想花几个星期的时间和太多的绑定元素使页面使用缓慢。thxIf它的大小是数百你会没事的thx-我通常只使用jQuery作为前端so和Vue的新手。我有点担心不必要的绑定和性能。该应用程序将在页面上显示数百个项目。在这种情况下,我应该限制绑定吗?或者,从性能角度看,这不应该是一个问题。我知道有点推测性,但我不想花几个星期的时间和太多的绑定元素使页面使用缓慢。Thxi如果在数百级你会没事的
<a :href="'/arc/locations/' + location.id + '/edit'">edit here</a>
computed: {
  url() {
    return '/arc/locations/' + this.location.id + '/edit';
  }
}