search

Home  >  Q&A  >  body text

javascript - vue parent-child component has problems passing data through attributes

Write an app component that contains a v-header component

Pass the seller to v-header through the following situation

Receive in the v-header component in the following form

But it keeps reporting errors

I don’t know if there is something wrong with the format

阿神阿神2749 days ago585

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 13:40:22

    The seller in the parent component is empty.
    Whether the seller has been defined in the data of the parent component

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 13:40:22

    There is no seller defined in the app component

    export default {
        data: function() {
            return {
                seller: {
                    avatar: ''
                }
            };
        }
    }

    And when initializing the seller, it is best to write down the key value of the seller

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 13:40:22

    You’d better take a look at the difference between prop and data. The error message is clearly written and seller is not defined

    reply
    0
  • Cancelreply