How to use in vue 3 setup script ?
See original GitHub issuetaking the first exemple of the doc and convert it to setup script break the exemple
<template>
<div ref="container" class="keen-slider">
<div class="keen-slider__slide number-slide1">1</div>
<div class="keen-slider__slide number-slide2">2</div>
<div class="keen-slider__slide number-slide3">3</div>
<div class="keen-slider__slide number-slide4">4</div>
<div class="keen-slider__slide number-slide5">5</div>
<div class="keen-slider__slide number-slide6">6</div>
</div>
</template>
<script setup lang="ts">
import { useKeenSlider } from 'keen-slider/vue.es'
import 'keen-slider/keen-slider.min.css'
// export default {
// setup() {
const [container, slider] = useKeenSlider({
loop: true,
})
// return { container }
// },
// }
</script>
<style>
body {
margin: 0;
font-family: 'Inter', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
[class^='number-slide'],
[class*=' number-slide'] {
background: grey;
display: flex;
align-items: center;
justify-content: center;
font-size: 50px;
color: #fff;
font-weight: 500;
height: 300px;
max-height: 100vh;
}
.number-slide1 {
background: rgb(64, 175, 255);
background: linear-gradient(
128deg,
rgba(64, 175, 255, 1) 0%,
rgba(63, 97, 255, 1) 100%
);
}
.number-slide2 {
background: rgb(255, 75, 64);
background: linear-gradient(
128deg,
rgba(255, 154, 63, 1) 0%,
rgba(255, 75, 64, 1) 100%
);
}
.number-slide3 {
background: rgb(182, 255, 64);
background: linear-gradient(
128deg,
rgba(182, 255, 64, 1) 0%,
rgba(63, 255, 71, 1) 100%
);
background: linear-gradient(
128deg,
rgba(189, 255, 83, 1) 0%,
rgba(43, 250, 82, 1) 100%
);
}
.number-slide4 {
background: rgb(64, 255, 242);
background: linear-gradient(
128deg,
rgba(64, 255, 242, 1) 0%,
rgba(63, 188, 255, 1) 100%
);
}
.number-slide5 {
background: rgb(255, 64, 156);
background: linear-gradient(
128deg,
rgba(255, 64, 156, 1) 0%,
rgba(255, 63, 63, 1) 100%
);
}
.number-slide6 {
background: rgb(64, 76, 255);
background: linear-gradient(
128deg,
rgba(64, 76, 255, 1) 0%,
rgba(174, 63, 255, 1) 100%
);
}
</style>
Result
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
script setup
<script setup> is a compile-time syntactic sugar for using Composition API inside Single-File Components (SFCs). It is the recommended syntax if you are ......
Read more >The 101 guide to Script Setup in Vue 3
Don't you know about Script Setup yet? Check out this short article now and learn the nicest way to define a Vue component...
Read more >Vue 3.2 - Using Composition API with Script Setup
Within the script block, we export an object with three keys: name, computed, and methods. If you are familiar with Vue, this should...
Read more >Vue.js 3 Script Setup Tutorial
How to use props with the script setup · setup(props) { // access props through // 'props' object props.propName } · <template> {{...
Read more >Explaining The New script setup Type in Vue 3
The <script setup> type is a proposed change in the Vue's Git RFCs. To be clear, this is not intended to completely replace...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Wow thanks that better than my hacky solution !
Hey,
the example works differently because the slider’s parents have a defined width. In my test with vite, the body was a flexbox by default.
Alternatively, you could use a ResizePlugin for this implementation: