获取文本字段值onkeyup vue js

Wes*_*nal 6 javascript vue.js

不使用v-model,如何在键入时检索文本字段的值?如果可能,不使用任何方法.

<input type="text" class="form-field"
    v-on:keyup="data.sample = this.target.value">
Run Code Online (Sandbox Code Playgroud)

我用了

  • THIS.VALUE
  • this.target.value

  • e.target.value

And*_*yan 16

解决方案是:

<input type="text" v-on:keyup="this.$data.name = $event.target.value">
Run Code Online (Sandbox Code Playgroud)

来自文档:

在侦听本机DOM事件时,该方法接收本机事件作为唯一参数.如果使用内联语句,该语句可以访问特殊的$ event属性:v-on:click ="handle('ok',$ event)"

的jsfiddle