I can't get the html field that fires the event in its event handler (in javascript is the event.target).
I've a form with:
My code is like the following:
var Main = {
    methods: {
      change(par) {
        console.log("The value is: " + par);
        //HERE I can't get "event.target"
      }
    }
};
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/[email protected]/lib/index.js"></script>
<div id="app">
  <template>
    <el-input @change="change" placeholder="Input something here"/>
  </template>
</div>
I know I can call different functions, and in each one I know who is the relative input, but I'd like to use a common one.
Following the stacktrace I saw in element-ui.common.js the code of event fire:
handleChange: function handleChange(event) {
  this.$emit('change', event.target.value);
},
And there element passes just the value to the event handler.
Anyway, any idea to get the event.target, please?
Thanks
You can use @input.native
var Main = {
    methods: {
      change(event) {
        console.log("The value is: " + event.target.value);
        //HERE I can't get "event.target"
      }
    }
};
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/[email protected]/lib/index.js"></script>
<div id="app">
  <template>
    <el-input @input.native="change" placeholder="Input something here"/>
  </template>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With