ant-design-vue/components/vc-slick/demo/DynamicSlides.jsx

44 lines
898 B
Vue
Raw Normal View History

2019-01-12 03:33:27 +00:00
import '../assets/index.less';
import Slider from '../src/slider';
2018-07-20 08:13:21 +00:00
export default {
2019-01-12 03:33:27 +00:00
data() {
2018-07-20 08:13:21 +00:00
return {
slides: [1, 2, 3, 4, 5, 6],
2019-01-12 03:33:27 +00:00
};
2018-07-20 08:13:21 +00:00
},
methods: {
2019-01-12 03:33:27 +00:00
click() {
this.slides = this.slides.length === 6 ? [1, 2, 3, 4, 5, 6, 7, 8, 9] : [1, 2, 3, 4, 5, 6];
2018-07-20 08:13:21 +00:00
},
},
2019-01-12 03:33:27 +00:00
render() {
2018-07-20 08:13:21 +00:00
const settings = {
props: {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 3,
slidesToScroll: 3,
},
2019-01-12 03:33:27 +00:00
};
2018-07-20 08:13:21 +00:00
return (
<div>
<h2>Dynamic slides</h2>
2019-01-12 03:33:27 +00:00
<button class="button" onClick={this.click}>
2018-07-20 08:13:21 +00:00
Click to change slide count
</button>
<Slider {...settings}>
2019-01-12 03:33:27 +00:00
{this.slides.map(function(slide) {
2018-07-20 08:13:21 +00:00
return (
<div key={slide}>
<h3>{slide}</h3>
</div>
2019-01-12 03:33:27 +00:00
);
2018-07-20 08:13:21 +00:00
})}
</Slider>
</div>
2019-01-12 03:33:27 +00:00
);
2018-07-20 08:13:21 +00:00
},
2019-01-12 03:33:27 +00:00
};