在饿了吗的项目中,shopcart 组件显示不了数据,我已经在外层的app.vue加了seller属性为什么还是不了呢??

在goods.vue中:

clipboard.png

在shopcart.vue中

clipboard.png

在外层的app.vue中

clipboard.png

我已经在app。vue加入了 :seller="serller"属性了,为什么还是没有定义minPrice??

有以下的错误:

clipboard.png

阅读 3k
4 个回答
  1. app.vue 传递,good.vue 接收:

    export default {
        props: {
              seller: {
                type: Object
              }
        }
     }
  2. good.vue 传递,shopcart.vue 接收

    export default {
        props: {
              deliveryPrice: {
                type: Number,
                default: 0
              },
              minPrice: {
                type: Number,
                default: 0
              }
            }
     }

deliveryPrice还有minPrice是你为shopcart定义的属性,需要接收

<shopcart :deliveryPrice="seller.deliveryPrice" :minPrice="seller.minPrice"></shopcart>

shopcart 里接收

export default {
             props:{
                 deliveryPrice:{
                    type:String,
                       default:'100'
                },
                 minPrice:{
                    type:String,
                       default:'100'
                }
             },
         }

在shopcart.vue里面要声明一个props minPrice,没有告诉它它不会去接收父组件传递过来的数据

已经解决了,谢谢各位好人了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题