如何绑定到 Vue JS 中的属性? [英] How to bind to attribute in Vue JS?
本文介绍了如何绑定到 Vue JS 中的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了这个错误
<块引用>属性内的插值已被删除.使用 v-bind 或冒号简写代替.例如,代替 <div id="{{ val }}">
,使用
.
在这条线上
它适用于 Angular 1.你如何在 Vue 中做到这一点?
解决方案
在您的模板中:
然后你把 href
放在 data
中:
new Vue({//...数据: {href: '你的链接'}})
或者使用计算属性:
new Vue({//...计算:{href(){返回 '/foo' + this.someValue + '/bar'}}})
I got this error
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">
.
on this line
<a href="/Library/@Model.Username/{{myVueData.Id}}">
It works in Angular 1. How do you do it in Vue?
解决方案
In your template:
<a :href="href">
And you put href
in data
:
new Vue({
// ...
data: {
href: 'your link'
}
})
Or use a computed property:
new Vue({
// ...
computed: {
href () {
return '/foo' + this.someValue + '/bar'
}
}
})
这篇关于如何绑定到 Vue JS 中的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文