1.0.0 • Published 7 years ago

vue-check-all v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

vue-lazy-render

GitHub issues GitHub forks GitHub stars Twitter

NPM

Description

vue check all component。

Dependence

  • vue: ^2.3.0

Installation

npm install vue-check-all

Usage

import CheckAll from 'vue-check-all'
Vue.use(CheckAll)

Props

propertydescriptiontypedefaultrequired
listThe data listArray[]true
check-allIf the list is all checked. If the value is true, the list will be all checked. Must use .sync modifier.Booleanfalsetrue

scopedSlot

propertydescriptiontype
listThe list contains the checked key and data key。If the checked is true, It means the data is checkedArray
selectionsThe items which are checked.Array
select-all-changeIf you want to change the checkAll prop,you should call this function,to notify the component update selections.Function

Events

namedescriptionparams
selectionswhen list item's checked is change, will emit this event.selections

Example

基础用法

<template>
  <check-all @selection-change="selectionChange" :list="list" :check-all.sync="checkAll">
    <template scope="scope">
      <label>
        <input type="checkbox" v-model="checkAll" @click="scope.checkAllChange">
        全选
      </label>
      <ul>
        <li v-for="item in scope.list" :key="item.data">
          <label>
            <input v-model="item.checked" type="checkbox">
            {{item.data}}
          </label>
        </li>
      </ul>
    </template>
  </check-all>
</template>

<script>
  export default {
    data () {
      return {
        list: [1,2,3],
        checkAll: true
      }
    },
    methods: {
      selectionChange (selections) {
        console.log(selections)
      }
    }
  }
</script>

Development

npm run dev
npm run port

Build

npm run mb // mac build
npm run wb // window build

License

MIT