plantain
V2EX  ›  问与答

使用 vuejs 时,在 v-repeat 内部使用 v-on, v-repeat 在 v-on 中的绑定失效,怎么办呢?

  •  
  •   plantain · Jul 6, 2015 · 2488 views
    This topic created in 4168 days ago, the information mentioned may be changed or developed.
    例如:

    <ul v-repeat='users'>
    <li><button v-on='click:deleteUser({{id}})'>delete {{name}}</button></li>
    </ul>

    其中的对id的绑定会失效
    2 replies  •  2015-07-06 17:29:12 +08:00
    oott123
    oott123
    Jul 6, 2015❤️1
    1
    <ul>
    <li v-repeat='users'><button v-on='click:deleteUser({{id}})'>delete {{name}}</button></li>
    </ul>
    icanfork
    icanfork
    Jul 6, 2015❤️1
    2
    <li><button v-on='click:deleteUser(this)'>delete {{name}}</button></li>

    deleteUser: function(item){
    console.log(item.id);
    this.users.$remove(item.$data);
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4748 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:17 · PVG 11:17 · LAX 19:17 · JFK 22:17
    ♥ Do have faith in what you're doing.