V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
coolair
V2EX  ›  问与答

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

  •  
  •   coolair · Apr 27, 2022 · 982 views
    This topic created in 1465 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   ·   2343 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 04:56 · PVG 12:56 · LAX 21:56 · JFK 00:56
    ♥ Do have faith in what you're doing.