项目作者: cagataykula

项目描述 :
A Vue.js component for image selection
高级语言: Vue
项目地址: git://github.com/cagataykula/v-select-image.git
创建时间: 2020-05-29T21:21:49Z
项目社区:https://github.com/cagataykula/v-select-image

开源协议:MIT License

下载


Vue Select Image

Vue Select Image is a Vue.js component for selecting images.
Vue Select Image Demo

Installation

Use the npm package manager to install it in your project.

  1. npm install --save v-select-image

Basic Usage

The most common usage is to pass a data array to the component and include it in your project.

  1. import vSelectImage from 'v-select-image'
  2. new Vue({
  3. el: '#select',
  4. template:'<v-select-image :items="myItems" v-model="selectedItems"></v-select-image>',
  5. components:{vSelectImage},
  6. data: {
  7. selectedItems:[],
  8. myItems: [
  9. {
  10. id: 1,
  11. title: '',
  12. backgroundImage: 'https://picsum.photos/300/300?id=1',
  13. selectable: true
  14. },
  15. {
  16. id: 2,
  17. title: '',
  18. backgroundImage: 'https://picsum.photos/300/300?id=2',
  19. selectable: true
  20. },
  21. {
  22. id: 3,
  23. title: '',
  24. backgroundImage: 'https://picsum.photos/300/300?id=3',
  25. selectable: true
  26. },
  27. {
  28. id: 4,
  29. title: '',
  30. backgroundImage: 'https://picsum.photos/300/300?id=4',
  31. selectable: true
  32. },
  33. {
  34. id: 5,
  35. title: '',
  36. backgroundImage: 'https://picsum.photos/300/300?id=5',
  37. selectable: true
  38. },
  39. {
  40. id: 6,
  41. title: '',
  42. backgroundImage: 'https://picsum.photos/300/300?id=6',
  43. selectable: true
  44. }],
  45. selectedVal: null
  46. }
  47. })

Parameters

You can use easily with use \ tag.
Example:

  1. <v-select-image
  2. class="w-650"
  3. v-model="selectedItems"
  4. :items="items"
  5. colorSchema="#8B8B8B"
  6. ></v-select-image>

Properties

You can add some parameters to customizing.
|Property|type|required | default|
|—|—|—|—|
|items|Array|true||
|colorSchema|String|false|#8B8B8B|
|maxSelectable|String/Integer|false|-1|
|uniqueKey|String|false|id|

Max Selection Error Handling

You can add @maxSelectionError prop to the \ tag to handle maximum number of selected items.

Example:

  1. <v-select-image
  2. class="w-650"
  3. v-model="selectedItems"
  4. :items="items"
  5. maxSelectable="3"
  6. @maxSelectionError="yourErrorFunction()"
  7. ></v-select-image>

Bugs and Improvements

If you can find a bug or design issues you can open an issue on GitHub. Don’t hesitate to contribute. Your feedback is appreciated!