vue props 传对象 undefined

问大家个问题,我props传desc对象的时候,为什么会显示undefined呢,我明明设置了默认值


<template>

  <transition name="slide">

    <div v-show="showFlag" class="food" ref="food">

        <ratingselect v-if="desc" :desc="desc" ></ratingselect>

    </div>

  </transition>

</template>


<script>

import ratingselect from '@/components/ratingselect/ratingselect'

export default {

  name: 'food',

  data () {

    return {

      desc: {

        all: '全部',

        positive: '推荐',

        negative: '吐槽'

      }

    }

  },

  components: {

    ratingselect

  }

}

</script>

<template>

  <div class="ratingselect">

    <div class="rating-type">

      <span>{{desc.all}}</span>

      <span>{{desc.positive}}</span>

      <span>{{desc.negative}}</span>

    </div>

    <div class="swith">

      <span class="icon-check_circle"></span>

      <span class="text">只看有内容的评价</span>

    </div>

  </div>

</template>


<script>

export default {

  prop: {

    desc: {

      type: Object,

      default () {

        return {

          all: '全部',

          positive: '满意',

          negative: '不满意'

        }

      }

    }

  },

  data () {

    return {

    }

  }

}

</script>

https://img.mukewang.com/5ce0d08600018aaa05600189.jpg

料青山看我应如是
浏览 1658回答 1
1回答

手掌心

props吧,你写的prop
打开App,查看更多内容
随时随地看视频慕课网APP