coolair
V2EX  ›  问与答

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

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