0

I have event on change and it return objcet data i need to get specific value from this data but I'm not sure how to.

Screenshot

one

Code

serviceSelected(event) {
    console.log('service event1: ', event)
    console.log('service event2: ', event.value) // undefined
}

Any ideas?

2 Answers 2

1

The event in this case is actually en array so you can access your value like this:

serviceSelected(event) {
    console.log(event[0].value)
}
Sign up to request clarification or add additional context in comments.

Comments

1

As @Pierre Said already given the answer. Here is more details about how Vue works.

Vue uses this.$refs to interact with DOM reference, you can use this or use app.input1 to set vue variable, where app is Vue object and input1 in data element

var app = new Vue({
  el:'#app',
  data:{
    input1: ''
  },
  methods:{
    method1: function (){
        console.log("Insidide Vue: ",this.$refs['input1'].value);
    }
  }
})

function method1(e){
app.input1 = $(e).val();
console.log("Outside Vue: ",$(e).val());
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<input @change="method1" onchange="method1(this)" ref="input1">
<div>input1 : {{input1}}</div>
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.