如何填充用 vuejs 2 隐藏的输入?

Fer*_*ong 0 function populate vue.js vuejs2

我想知道如何将返回此函数的值传递给隐藏的输入我尝试使用指令 v-input 但不起作用,我如何找到解决方案?这是计算函数:

  computed:{
        currentDate: function (){
        this.date = moment().format("D-MM-YYYY");
        return this.date;

    }
Run Code Online (Sandbox Code Playgroud)

这就是观点:

   <input type="hidden" name="customfield" class="form-control" v-model="fillProfile.customfield">
Run Code Online (Sandbox Code Playgroud)

Roy*_*y J 6

如果您希望currentDate成为隐藏字段的值,则应该像这样绑定它:

<input type="hidden" name="customfield" class="form-control" :value="currentDate">
Run Code Online (Sandbox Code Playgroud)

v-model是双向绑定,隐藏的输入不是交互式的,因此使用它是没有意义的。