Vue 2: Get input value without using v-model

1
I'm already detecting when enter is pressed in input , how can I get the current value in> too? It can not be with v-model , because I need to leave a default value, as shown in the example below:

HTML

<div id="listas-page">
     @foreach($listas as $lista)
          <input type="text" value="{{$lista->descricao}}" v-on:keyup.13="editName">
     @endforeach
</div>

JS

var listasPage = new Vue({
    el: '#listas-page',

    methods: {
        editName(event) {
            console.log(event);
        }
    }
});
    
asked by anonymous 22.01.2018 / 14:16

1 answer

4

I do not recommend this merge of pure php with vue, there are better solutions, but you can get the value from event.target.value , example ...

new Vue({
  el: '#app',
  data : {
  	value : ''
  },
  methods : {
    editName(event) {
      this.value = event.target.value;
    }
  }
})
<script src="https://unpkg.com/vue"></script><divid="app">
  <input value="default" v-on:keyup.13="editName">
  {{value}}
</div>
    
22.01.2018 / 16:24