GithubHelp home page GithubHelp logo

vue-select's Introduction

vue-select

VUE Select component

使用方法:

  1. 引入组件:
import VueSelect from '../components/VueSelect'
  1. 注册组件
export default {
    components: {
        VueSelect
    }
}
  1. 使用组件
<template>
    <vue-select
     :options="options"
     name="name"
     value="id"
     placeholder="请选择类型"
     v-model="selected_id"
     @change="handleChange">
    </vue-select>
</template>

options:选择项列表;

name:选择项列表中选择项名称的属性名;

value:选择项列表中选择项的值的属性名;

v-model:对应双向绑定的选中后的值;

@change:选择发生改变后触发事件,回调参数:当前选项。

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>

vue-select's People

Contributors

tuohuang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.