我正在使用vue-router。将值绑定到链接url
如何将值绑定到链接?
<a v-link="'people/edit/{{ item.id }}'">Edit</a>
错误:
link="'people/edit/{{ item.id}}'": attribute interpolation is not allowed in Vue.js directives and special attributes.
我正在使用vue-router。将值绑定到链接url
如何将值绑定到链接?
<a v-link="'people/edit/{{ item.id }}'">Edit</a>
错误:
link="'people/edit/{{ item.id}}'": attribute interpolation is not allowed in Vue.js directives and special attributes.
您可以简单地使用+
这里在连接字符串,因为v-link
接受JavaScript表达式:
<a v-link="'people/edit/' + item.id">Edit</a>
v-link
is the directive for enabling user navigation in a router-enabled app. It accepts a JavaScript expression which will be passed torouter.go()
internally.
https://github.com/vuejs/vue-router/blob/1.0/docs/en/link.md
虚连接属性指定文档中访问过的链接的颜色,它不是用来作为你使用它。在vlink的地方使用链接href。如下面
<a href="people/edit/${item.id}"></a>
因为我们vue-router,链接不是http:// localhost:8080 /#!/ people/edit/3871287183 – Alvin
不能使用小胡子到V-链接,v链接基本上是香草js,并且胡须作为模板部分是不允许的。
如果您使用的是ES2015,则可以使用模板字符串。
<a v-link="`/people/edit/${item.id}`">Link</a>
'v-link =''people/edit /'+ item.id“'? – Dogbert
@Dogbert它的工作原理... – Alvin