1

我有一个使用 VueJs 表单生成器的动态表单,使用像 textBox 或文本区域这样的简单按钮我更新了模型数组和模式数组,并像这样使用它,

var fromControlRules = new Vue({
    el: '#form',
    components: {
        "vue-form-generator": VueFormGenerator.component
    },
    data() {
        return {
            model: {
                model: formModel (//array of model)
            },
            schema: {
                fields: formSchema (//array of schema)
            },
            formOptions: {
                validateAfterLoad: true,
                validateAfterChanged: true
            }
        }
    },

'formSchema' 是这样的,

formSchema = [
{
  type: "input",
    inputType: "text",
    label: "Name of the field",
    model: "name"
},
{
    type: "input",
    inputType: "text",
    label: "Type of the field",
    model: "type"
}];

在提交或取消模态表单时,我想清除模型,但是当我看到字段仍然存在的表单时不会发生。让我知道如何重置表单,以便我可以创建一个新表单,这一次可能使用日期字段和下拉列表而不是文本框。

4

1 回答 1

1

UPD:你不需要使用Vue.set,试试这个:

formSchema.splice(0, formSchema.length)

于 2018-08-28T07:08:17.287 回答