我想将包含多个值的字符串绑定(bind)到 vuetify 中的文本字段。我编写了以下代码,但它为我提供了字符串形式的属性。
<div v-if="textField">
<v-text-field
:value="'Our client, {{this.name}}, is {{this.age}} years old.'"
outline
readonly
>
</v-text-field>
</div>
输出是:
Our client, {{this.name}}, is {{this.age}} years old.
尽管我想得到 this.name 和 this.age 的值是 John 和 32像这样:
Our client, John, is 32 years old.
最好的方法是什么?
最佳答案
或者使用template literals直接在模板中作为:
<v-text-field
:value="`Our client, ${name}, is ${age} years old.`"
outline
readonly
>
另请注意 Mustaches cannot be used inside HTML attributes .也就是说,{{}}
不适用于属性。
关于javascript - 将多个属性绑定(bind)到 Vuetify 中的文本字段标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52728489/