search

Home  >  Q&A  >  body text

javascript - Problem with props value transfer in vue?

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>
typechotypecho2816 days ago873

reply all(3)I'll reply

  • 扔个三星炸死你

    扔个三星炸死你2017-06-15 09:25:17

    <img-box :obj='item'></img-box>
    let {value, activeParam, aimUrl, jumpType, setTop, setWidth, themeId, todocode, toolId,  ttid} = item;

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-06-15 09:25:17

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

    reply
    0
  • 習慣沉默

    習慣沉默2017-06-15 09:25:17

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

            obj:{},
        }

    I will receive the item directly

    reply
    0
  • Cancelreply