VUE 饿了么项目实战 VUE "TypeError: Cannot read property 'deliveryPrice' of undefined"报错

<shopcart :delivery-price="seller.deliveryPrice" :min-price="seller.minPrice"></shopcart>中.VUE "TypeError: Cannot read property 'deliveryPrice' of undefined"报错

1、在app.vue中把seller传进来

<router-view seller="seller"></router-view>

2、在goods.vue把seller传递到shopcart.vue组件

<shopcart :delivery-price="seller.deliveryPrice" :min-price="seller.minPrice"></shopcart>

前提是在goods.vue中已经引入seller

props: {

    seller: {

      type: Object

    }

  }

在shopcart中接收(props)这个值,

<div class="desc">另需配送费{{deliveryPrice}}元</div>

props: {

    deliveryPrice: {

      type: Number,

      default: 0

    },

    minPrice: {

      type: Number,

      default: 0

    },

  },

原文地址:https://www.cnblogs.com/haimeimei/p/13228313.html