javascript - vue中props傳值的問題?
typecho
typecho 2017-06-15 09:23:17
0
3
867

父元件給子元件傳遞一個物件item,發現用方法一的時候子元件中接收到的item裡每個屬性都會多出get/set方法,如果屬性比較多方法二太煩了,請教大神們是怎麼做的


方法一:
<img-box :obj='item'></img-box>
方法二:
<img-box
      :value='item.value'
      :activeParam='item.activeParam'
      :aimUrl='item.aimUrl'
      :jumpType='item.jumpType'
      :setTop='item.setTop'
      :setWidth='item.setWidth'
      :themeId='item.themeId'
      :todocode='item.todocode'
      :toolId='item.toolId'
      :ttid='item.ttid'
    ></img-box>
typecho
typecho

Following the voice in heart.

全部回覆(3)
我想大声告诉你

就直接傳一個物件過去,然後子元件用物件接收

習慣沉默

父組件:
子組件: props:{

        obj:{},
    }

直接不就接收到item了

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板