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.0
  • 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

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``` are 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
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
disabledBooleanfalsewhether to disable components
piecewiseBooleanfalsedisplay of the piecewise
tooltipString,Booleanfalsecontrol the tooltip ['hover', 'always', false]
valNumber0initial value
dataArraynullthe custom data

Function

| Name | Params&Type | Description | | ----------- |:--------------| ---------|--------------| | setValue | value[Number] | set value of the component | | setIndex | index[Number] | set index of the component (Particularly useful in [used piecewise] or [the custom data]) | | refresh | null | Refresh the component |

Events

NameParams&TypeDescription
callbackvalue[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 29 Sep 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