undefinedfix
Sign in

How can the selected value in the select selector in elementui be passed to the parent component?

aleonjhon edited in Thu, 24 Nov 2022

Dear masters, there is a select selector that I often use, so I have registered it as a small component. I want to pass the selected value to the parent component in the form of emit: first, write down the code of the selector in the child component, and bind it with its own change event: < El select V-model = "kkkvalue" placeholder = "please select" >... <script>change(){var that = this;this.$emit('to_ fuzujian', that.kkkvalue );}... Then register and receive the incoming kkkvalue value in its parent component and store it into the value of the parent component_ In KKK: < selectdemo @ to_ fuzujian="to_ fu"></selectdemo>。。。 methods: {to_ fu(data) { this.value_ kkk = data;}...

Finally, it can't be displayed normally. What's the matter with you masters?

2 Replies
E_D
commented on Fri, 25 Nov 2022

< El select V-model = "kkkvalue" placeholder = "please select" > you are not listening to the change event in this code

Vin
commented on Fri, 25 Nov 2022
<selectdemo :to_fuzujian="to_fu"></selectdemo>
...
...
data() {
  return {
    to_fu: '' //每次选中后,to_fu会直接更新
  }
},