plantain
V2EX  ›  问与答

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

  •  
  •   plantain · Jul 6, 2015 · 2415 views
    This topic created in 4062 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
        1
    oott123  
       Jul 6, 2015   ❤️ 1
    <ul>
    <li v-repeat='users'><button v-on='click:deleteUser({{id}})'>delete {{name}}</button></li>
    </ul>
    icanfork
        2
    icanfork  
       Jul 6, 2015   ❤️ 1
    <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   ·   Solana   ·   1010 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 19:27 · PVG 03:27 · LAX 12:27 · JFK 15:27
    ♥ Do have faith in what you're doing.