coolair
V2EX  ›  问与答

Vue2 有办法删除 props 里面一个 object 的 key 吗?

  •  
  •   coolair · Apr 27, 2022 · 1002 views
    This topic created in 1477 days ago, the information mentioned may be changed or developed.
    使用 this.$delete 发现没有效果。
    3 replies    2022-04-27 16:32:47 +08:00
    MEIyiyi
        1
    MEIyiyi  
       Apr 27, 2022
    props 不都是父组件传进来的吗,根据单向数据流,是没法删的吧。要删的话就用事件 on/emit 删?
    nitmali
        2
    nitmali  
       Apr 27, 2022
    可以,直接 `` delete component.$props.key ``
    coolair
        3
    coolair  
    OP
       Apr 27, 2022
    @nitmali 在子组件中可以吗?刚试了下,只是删了数据,页面没有响应更新。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5848 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 01:58 · PVG 09:58 · LAX 18:58 · JFK 21:58
    ♥ Do have faith in what you're doing.