javascript - vue中props传值的问题?
typecho
typecho 2017-06-15 09:23:17
0
3
871

父组件给子组件传递一个对象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)
我想大声告诉你

就直接传一个对象过去,然后子组件用对象接收

習慣沉默

父组件:<img-box :obj='item'></img-box>
子组件: props:{

        obj:{},
    }

直接不就接收到item了

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板