Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-slider-component

Package Overview
Dependencies
Maintainers
1
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-slider-component

Can use the Slider component in vue1.x and vue2.x

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59K
decreased by-8.72%
Maintainers
1
Weekly downloads
 
Created
Source

vue-slider-component

Can use the slider in vue1.x and vue2.x

demo

Install

npm install vue-slider-component

Todo

  • Basis
  • Display maximum value & minimum value
  • piecewise style
  • Compatible with PC and mobile terminal
  • Tooltip
  • The custom data
  • Range

Example

cd vue-slider-component/example
npm install
npm run dev
npm run build

usage

Use in vue1.x

e.g:

<template>
    <div>
        <vue-slider v-ref:slider :val.sync="val" @callback="getValue"></vue-slider>
    </div>
</template>
<script>
import { vueSlider }  from 'vue-slider-component';

new Vue({
  el: '#app',
  components: {
    vueSlider
  },
  data: {
    val: 1
  }
  methods: {
    getValue(val) {
      console.log(val)
    },
    setValue(num) {
      this.val = num
    }
  }
});
</script>

Use in vue2.x
Because```.sync``` was deprecated. Props are now always one-way down. So in order to realize the two-way, Can be set in the @callback

e.g:

<template>
    <div>
        <vue-slider ref="slider" :val="val" @callback="getValue"></vue-slider>
    </div>
</template>
<script>
// import { vue2Slider as vueSlider } from 'vue-sliders-component';
import vueSlider from 'vue-sliders-component/vue2-sliders.vue'

new Vue({
  el: '#app',
  components: {
    vueSlider
  },
  data: {
    val: 1
  }
  methods: {
    getValue(value) {
      /* Two-way */
      this.val = value
    },
    setValue(num) {
      this.val = num
    }
  }
});
</script>

Options

Props

PropsTypeDefaultDescription
class-nameStringnullthe custom class
stylesObjectnullthe custom styles
eventTypeString'auto'the event type, optional value: ['auto', 'touch', 'mouse', 'none']
widthNumber,String150width of the component
heightNumber4height of the component
dotSizeNumber15size of the sliders
minNumber0the minimum value
maxNumber100the maximum value
intervalNumber1the gap between the values
showBooleantruedisplay of the component
speedNumber0.5transition time
disabledBooleanfalsewhether to disable components
piecewiseBooleanfalsedisplay of the piecewise
tooltipString,Booleanfalsecontrol the tooltip, optional value: ['hover', 'always', false]
valNumber,Array0initial value (if the value for the array open range model)
dataArraynullthe custom data

Function

NameTypeDescription
setValueParams: value[Number, Array]set value of the component
setIndexParams: index*[Number]set index of the component
getValueReturn: value[Number, Array]get value of the component
getIndexReturn: index*[Number]get index of the component
refreshnullRefresh the component
  • [ index ] is the index to the array in the custom data model *
  • [ index ] is equal to (( value - min ) / interval ) in normal mode *

Events

NameTypeDescription
callbackParams:value[Number]values change when the callback function

Slot

default:

<slot name="left">{{ min }}</slot>
<slot name="right">{{ max }}</slot>

custom:

<template>
  <vue-slider ref="slider" :min="minimum" :max="maximum" :val="val" @callback="getValue">
    <p slot="left">${{ minimum }}.00</p>
    <p slot="right">${{ maximum }}.00</p>
    <!-- or -->
    <!--
      <span slot="left"></span>
      <p slot="right">value: {{ val }}</p>
    -->
  </vue-slider>
</template>

FAQs

Package last updated on 10 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc