The specific code is as follows:
<template> <div> <el-select v-model="typeValue" placeholder="Please select the package type" @change='typeValChange' > <el-option v-for="item in typeData" :key="" :label="" :value="" :disabled="" > </el-option> </el-select> </div> </template> <script> export default { name: "AppTypeSelect", props: {}, data: function() { return { typeData: [{ label: "t1", id: 1 }, { label: "t2", id: 2 }], typeValue: "" }; }, methods: { typeValChange() { (); this.$emit("input", ); } } }; </script> <style scoped> </style>
`This is a subcomponent
Here is the parent component
`
<template> <div> <AppTypeSelect v-model="absc" /> </div> </template> <script> import { getModelList, deleteModel } from "@/api/model"; import AppTypeSelect from "@/components/AppTypeSelect"; export default { name: "abcs", components: { AppTypeSelect }, data() { return { listQuery: { page: "1" }, loading: false, form: { config_id: "" }, tableData: [], pageCount: 0, addDialogVis: false, absc:'' }; }, watch:{ absc:function(val){ (val) } }, methods: { } }; </script> <style scoped> .line { text-align: center; } .page-title { height: 30px; color: #409eff; } label { color: #606266; font-size: 16px; } </style>
Summarize
The above is the code that the vue parent component receives the values of the child component through v-model that the editor introduces to you. I hope it will be helpful to everyone!