Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
vue-slider-component
Advanced tools
The vue-slider-component is a highly customizable slider component for Vue.js. It allows developers to create sliders with a wide range of features, including custom styles, tooltips, and various configurations for different use cases.
Basic Slider
This code demonstrates a basic slider component with a default value of 50. The slider is imported and used within a Vue component.
<template>
<vue-slider v-model="value"></vue-slider>
</template>
<script>
import VueSlider from 'vue-slider-component'
import 'vue-slider-component/theme/default.css'
export default {
components: { VueSlider },
data() {
return {
value: 50
}
}
}
</script>
Range Slider
This code demonstrates a range slider with a minimum value of 0, a maximum value of 100, and an interval of 1. The tooltip is always visible, and the initial range is set to [20, 80].
<template>
<vue-slider v-model="value" :min="0" :max="100" :interval="1" :tooltip="'always'"></vue-slider>
</template>
<script>
import VueSlider from 'vue-slider-component'
import 'vue-slider-component/theme/default.css'
export default {
components: { VueSlider },
data() {
return {
value: [20, 80]
}
}
}
</script>
Custom Tooltip
This code demonstrates a slider with a custom tooltip formatter. The tooltip always shows and displays the value prefixed with 'Value: '.
<template>
<vue-slider v-model="value" :tooltip="'always'" :formatter="formatter"></vue-slider>
</template>
<script>
import VueSlider from 'vue-slider-component'
import 'vue-slider-component/theme/default.css'
export default {
components: { VueSlider },
data() {
return {
value: 50
}
},
methods: {
formatter(val) {
return `Value: ${val}`;
}
}
}
</script>
The vue-range-component is another Vue.js component for creating sliders. It offers similar functionalities such as range selection, custom tooltips, and various configurations. However, it may not be as feature-rich or customizable as vue-slider-component.
The vue-slider package provides a simple and easy-to-use slider component for Vue.js. It supports basic slider functionalities and is suitable for simpler use cases. It may lack some of the advanced customization options available in vue-slider-component.
Can use the slider in vue1.x and vue2.x
npm install vue-slider-component --save
lazy
prop*-style
for the custom styleformatter
propclickable
proptooltipDir
and sliderStyle
and tooltipStyle
prop support type: Arrayreal-time
prop for real-time computing the layout of the componentscd example/
# install dependencies
npm install
# serve with hot reload at localhost:9000
npm run dev
Use in vue1.x
e.g:
<template>
<div>
<vue-slider v-ref:slider :value.sync="value"></vue-slider>
</div>
</template>
<script>
import vueSlider from 'vue-slider-component/src/vue-slider.vue';
new Vue({
el: '#app',
components: {
vueSlider
},
data: {
value: 1
}
});
</script>
e.g:
<template>
<div>
<vue-slider ref="slider" v-model="value"></vue-slider>
</div>
</template>
<script>
import vueSlider from 'vue-slider-component'
new Vue({
el: '#app',
components: {
vueSlider
},
data: {
value: 1
}
});
</script>
e.g:
import vueSlider from 'vue-slider-component/src/vue2-slider.vue'
Props | Type | Default | Description |
---|---|---|---|
direction | String | horizontal | set the direction of the component, optional value: ['horizontal', 'vertical'] |
event-type | String | auto | the event type, optional value: ['auto', 'touch', 'mouse', 'none'] |
width | Number[,String(in horizontal)] | auto | width of the component |
height | Number[,String(in vertical)] | 6 | height of the component |
dot-size | Number | 16 | size of the sliders |
min | Number | 0 | the minimum value |
max | Number | 100 | the maximum value |
interval | Number | 1 | the gap between the values |
show | Boolean | true | display of the component |
speed | Number | 0.5 | transition time |
disabled | Boolean | false | whether to disable components |
piecewise | Boolean | false | whether to display the piecewise |
piecewise-label* | Boolean | false | whether to display the label. demo here |
tooltip | String, Boolean | false | control the tooltip, optional value: ['hover', 'always', false] |
tooltip-dir | String[,Array(in range model) | top(in horizontal)or left(in vertical) | set the direction of the tooltip, optional value: ['top', 'bottom', 'left', 'right'] |
reverse | Boolean | false | whether the component reverse (such as Right to left, Top to bottom) |
value | Number,Array | 0 | initial value (if the value for the array open range model) |
data | Array | null | the custom data. |
clickable | Boolean | true | Whether or not the slider is clickable as well as drag-able |
real-time* | Boolean | false | Whether the real-time computing the layout of the components |
lazy* | Boolean | false | At the end of the drag and drop, to synchronization value (if each update to high consumption of operation (such as Ajax), it is more useful) |
formatter* | String,Function | null | Formatting a tooltip values, Example: formatter='¥{value}' or formatter: (v) => `¥${v}` . demo here |
bg-style* | Object | null | The style of the background. |
slider-style* | Object[,Array(in range model)] | null | The style of the slider. |
process-style* | Object | null | The style of the process bar. |
piecewise-style* | Object | null | The style of the piecewise dot. |
piecewise-active-style* | Object | null | The style of the piecewise dot in the activated state. |
tooltip-style* | Object[,Array(in range model)] | null | The style of the tooltip. |
label-style* | Object | null | The style of the label. |
label-active-style* | Object | null | The style of the label in the activated state. |
prop*: [only support vue2]
Name | Type | Description |
---|---|---|
setValue | Params: value | set value of the component |
setIndex | Params: index* | set index of the component |
getValue | Return: value | get value of the component |
getIndex | Return: index* | get index of the component |
refresh | null | Refresh the component |
Name | Type | Description |
---|---|---|
callback | Params: value[Number] | values change when the callback function |
drag-start | Params: context[Object] | Drag the staUnable to initialize the width componentsrt event |
drag-end | Params: context[Object] | Drag the end event |
if the component initialization in a v-show="false" / display: none
container or use transform / animation
to appear component, there may be an exception ( The slider cannot be used, because the component can not initialize the size or slider position ).
The solution:
:real-time="true"
, if the initial value not equal to the minimum, need to call the refresh
methodv-if
instead of v-show
or display: none
.show
to control display.refresh
method.FAQs
A highly customized slider component
The npm package vue-slider-component receives a total of 107,239 weekly downloads. As such, vue-slider-component popularity was classified as popular.
We found that vue-slider-component demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.