0

我试图使用 v-bind 将数据传递给子组件,用于我的 vue 公式表单输入。我在父母中传递了这样的数据。

<ChildForm v-bind:formData="formData" ></ChildForm>

    export default {
      name: "Parent",
      data() {
        return {

    formData: {
          Full_Name: "",
          Notes: "",
          Address: "",
          Phone: "",
          City: "",
          State: "",
          Zip: "",
    },
    }}}

在 Child 中,我正在这样做

    <FormulateForm v-model="formData">
      <FormulateInput
                type="textarea"
                name="Notes"
                label="NOTES"
                validation="required|max:200,length"
                validation-name="Notes"
                :help="`Keep it under 200 characters. ${200 - this.formData.Notes.length} left.`"
              />

      <FormulateInput
               type="submit"
               label="Submit Details"
               />
    </FormulateForm>

export default {
  name: "ChildForm",
  props: {
    formData: Object,
  },
}

但我收到以下错误

Error in render: "TypeError: Cannot read property 'length' of undefined"

知道可能是什么问题吗?

4

1 回答 1

1

你应该使用

formData.Notes.length

代替

this.formData.Notes.length
于 2020-07-13T01:32:33.333 回答