GithubHelp home page GithubHelp logo

vue-selectbox's Introduction

@moodles/vue-selectbox

A useful selectbox component for vue.js

Installation

webpack

npm i --save @moodles/vue-selectbox

browser

Grab vue-selectbox.js from dist folder and include it using a regular script tag

<script src="js/vue.js"></script>
<script src="js/vue-selectbox.js"></script>

Initialization

webpack
import { SelectBox } from '@moodles/vue-selectbox';

const app = new Vue({
    el: '#app',
    components: {
        'select-box': SelectBox
    }
})
browser
<script src="js/vue.js"></script>
<script src="js/vue-selectbox.js"></script>

<script>
    Vue.use(VueSelectBox);

    var app = new Vue({
        el: '#app',
    });
</script>

Component usage

When just using the component without any props, it will just show a default list of items.

<select-box></select-box>

The available props are:

Prop Type Default Description
title String Title Title above the component
data Array [ { id: 1, email: [email protected] }, ... ] Dataset used in the component
checked Array [] Array of prechecked values
labelKey String email Key of property in data of which label you want to show per item
valueKey String id Key of property in data of which you want to use as the value per item
inputName String data Name which is used as the name attribute on the checkboxes
Example of prop usage
//some-vue-or-js-file
...
data() {
    return {
        employees: [
            { id: 1, name: 'John Doe' },
            { id: 2, name: 'Lance Bogrol' },
            { id: 3, name: 'Will Barrow' },
            { id: 4, name: 'Hanson Deck' },
            { id: 5, name: 'Desmond Eagle' },
        ],
        checkedEmployees: [2, 4, 5]
    }
}
...

...
//some-html-file
<select-box
    title="Employees"
    label-key="name"
    value-key="id"
    input-name="employees"
    :data="employees"
    :checked="checkedEmployees"
></select-box>
...

vue-selectbox's People

Contributors

jannick94 avatar

Watchers

Li Yi avatar James Cloos 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.