javascript - Problem with props value transfer in vue?
typecho
typecho 2017-06-15 09:23:17
0
3
809

The parent component passes an object item to the child component. It is found that when using method one, each attribute in the item received in the child component will have an additional get/set method. If there are many attributes, method two is too annoying. Please ask an expert for advice. How did they do it


方法一:
<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.

reply all(3)
扔个三星炸死你
<img-box :obj='item'></img-box>
let {value, activeParam, aimUrl, jumpType, setTop, setWidth, themeId, todocode, toolId,  ttid} = item;
我想大声告诉你

Just pass an object directly, and then the sub-component uses the object to receive it

習慣沉默

Parent component: <img-box :obj='item'></img-box>
Child component: props:{

        obj:{},
    }

I will receive the item directly

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!