时间:2020-10-31 19:19:49 | 栏目:vue | 点击:次
今天用Vue做一个小项目时需要用到多个select筛选功能,但是原生的太丑,如果直接写在当前页多个select处理起来又太繁琐,第三方ui又太大,所以就自己写了一个,并上传了GitHub仓库,仓库地址:https://github.com/tuohuang/vue-select
使用方法:
引入组件:
import VueSelect from '../components/VueSelect'
注册组件
export default { components: { VueSelect } }
使用组件
<template> <vue-select :options="options" name="name" value="id" placeholder="请选择类型" v-model="selected_id" @change="handleChange"> </vue-select> </template>
DEMO:
<template> <div> <vue-select :options="options" name="name" value="id" placeholder="请选择一个水果" v-model="selected_id" @change="handleChange"> </vue-select> </div> </template> <script> import VueSelect from '../components/VueSelect' export default { name: "Index", data() { return { selected_id: "", options: [ {name: "苹果", id: 1}, {name: "橘子", id: 2}, {name: "香蕉", id: 3}, {name: "西瓜", id: 4}, ] } }, components: { VueSelect }, methods: { handleChange(e) { console.log(e) } } } </script>