search

Home  >  Q&A  >  body text

javascript - How to pass the dom bound to the current instruction in the vue instruction

<td contenteditable="true" @input="inputEvent()"></td>

You need to pass in the td dom element in inputEvent();

过去多啦不再A梦过去多啦不再A梦2808 days ago496

reply all(5)I'll reply

  • PHP中文网

    PHP中文网2017-05-19 10:13:27

    https://vuejs.org/v2/guide/ev...

    reply
    0
  • 高洛峰

    高洛峰2017-05-19 10:13:27

    Why do we need to pass it? Isn’t it in the event object?

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:13:27

    <body>
      <p id="app">
        <button @click='add'>按钮</button>
      </p>
    </body>

      new Vue({
        el: "#app",
        methods: {
          add(e) {
            console.log(e.target)
          }
        }
      })
    

    Is this what you mean? ?

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-19 10:13:27

    If there are no parameters, just set an event in the receiving method
    function (event) {}
    If there are other parameters, use inputEvent($event,other)

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-19 10:13:27

    // 传一个event
    @input="inputEvent($event)" 
    
    inputEvent(e) {
    console.log(e.path[0]. outerHTML)
    }

    reply
    0
  • Cancelreply