简体   繁体   中英

Vue.js object mapping

i have such object

data: () => ({
            customer: {
                item: {
                    name: undefined
                }}
})

in the template I'm using

<v-number
separator="."
decimal="2"
group-by="3"
error-text="system.global.cusotmer"
v-model="customer.item.name"
></v-number>

but i get an error:

[Vue warn]: Error in render: "TypeError: Cannot read property 'name' of undefined"

what i'm doing wrong?

this works fine:

data: () => ({
            customer: {
                item: undefined}
})
v-model="customer.item"

Try this syntax

data() {
  return {
    customer: {
      item: {
        name: undefined
      }
    }
  }
},

Also, please provide more context on what v-model is applied to and what your template is actually doing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM