文本字段有点像这样:

<v-text-field v-model="input" placeholder="(0 - 200)">
</v-text-field>

Vue.js data包含:
export default {
data () {
    return {
        input: '',
        proposed: 0
        }
    }
}

我希望占位符显示如下内容:
placeholder="Proposed quantity: 2 (0 - 200)"
尝试通过以下方式设置proposed变量:
a) placeholder="Proposed quantity: {proposed} (0 - 200)"
b) placeholder="Proposed quantity: `${proposed}` (0 - 200)"
c) placeholder="Proposed quantity: " + proposed + " (0 - 200)"

都没有。

还有其他想法和建议吗?

最佳答案

您必须使用placeholder:v-bind:placeholder ...绑定(bind)到数据对象,例如:

  :placeholder="'Proposed quantity: '+proposed+ ' (0 - 200)'"

要么
  v-bind:placeholder="'Proposed quantity: '+proposed+ ' (0 - 200)'"

09-11 07:52