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

标签 javascript html web vue.js vuetify.js

我想将包含多个值的字符串绑定(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/

相关文章:

javascript - 使变量值为正

Javascript - 我可以获得子窗口的网址吗?

javascript - 将 sortable.js 与 HTML 自定义数据属性结合使用

javascript - angular ng-repeat 根据条件添加样式

css - 使用 HTML 和 CSS 溢出到正文中?

angularjs - Web 应用 list : hash in start_url

javascript - 从 webapp 传递搜索词显示结果

Javascript - 反转正则表达式

html - 使用显示 : inline-block; inside <a> tags 时出现奇怪的线条

css - 在 Wordpress 博客中操作 css