为了账号安全,请及时绑定邮箱和手机立即绑定

vue props 传对象 undefined

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>
查看完整描述

1 回答

?
手掌心

TA贡献1942条经验 获得超3个赞

props吧,你写的prop


查看完整回答
反对 回复 2019-05-19
  • 1 回答
  • 0 关注
  • 1609 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信