1. 程式人生 > >vue簡單下拉框元件

vue簡單下拉框元件

export default{ data(){ return{ showData: false } }, props: { dataList:Array, selectedValue: Object,//傳回父元件的選擇值 widthData:{ type: String, default: "160px" } }, methods: { showDataList(){ this.showData=!this
.showData }, select(item,index){ this.showData=false; console.log("選擇"); console.log(item); console.log(index); //this.selectedValue=item; //賦值的時候要分開寫 this.selectedValue.key=item.key; this.selectedValue.value=item.value; this
.$emit('select'); console.log("0"+this.selectedValue.value); }, }, mounted(){ } }