問大家個問題,我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>
vue props 傳對象 undefined
料青山看我應如是
2019-04-10 18:19:04