gpt4 book ai didi

javascript - 将多个属性绑定(bind)到 Vuetify 中的文本字段标签

转载 作者:搜寻专家 更新时间:2023-10-30 22:20:32 24 4
gpt4 key购买 nike

我想将包含多个值的字符串绑定(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.namethis.age 的值是 John32像这样:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com