Skip to content
This repository was archived by the owner on Jul 10, 2019. It is now read-only.

Commit eb946e0

Browse files
committed
feat: add vue-carousel of npm module and example
1 parent f42a3ba commit eb946e0

File tree

6 files changed

+75
-2
lines changed

6 files changed

+75
-2
lines changed

nuxt.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ module.exports = {
9797
'@/plugins/constants-inject.ts',
9898
'@/plugins/env-inject.ts',
9999
'@/plugins/vue-lazyload.ts',
100-
'@/plugins/i18n.ts'
100+
'@/plugins/i18n.ts',
101+
{ src: '@/plugins/vue-carousel.ts', ssr: false }
101102
],
102103

103104
/*

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"nuxt-env": "^0.1.0",
6565
"nuxt-property-decorator": "^2.1.3",
6666
"ts-node": "^8.1.0",
67+
"vue-carousel": "^0.18.0",
6768
"vue-i18n": "^8.10.0",
6869
"vue-lazyload": "^1.2.6"
6970
},

src/pages/example/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ section
4949
nuxt-link(to='/example/animejs') animejs
5050
p
5151
nuxt-link(to='/example/now-utcoffset') now-utcoffset
52+
p
53+
nuxt-link(to='/example/vue-carousel') vue-carousel
5254
</template>
5355

5456
<script lang="ts">

src/pages/example/vue-carousel.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template lang="pug">
2+
section.container
3+
h1.title
4+
| vue-carousel
5+
div.example
6+
carousel(:navigationEnabled='true', :perPage='2')
7+
slide(v-for='i in loopCounter', :key='i', :data-index='i' @slideclick='handleSlideClick')
8+
span.label
9+
| {{i}}<img src='~/assets/images/lemon-sour.small.jpg'>
10+
p {{clickCounter}}
11+
</template>
12+
13+
<script lang="ts">
14+
import { Component, Vue } from 'nuxt-property-decorator'
15+
// https://qiita.com/gakumac/items/cc3f1bb0dfcbbefa1eeb
16+
import Carousel from 'vue-carousel/src/Carousel.vue'
17+
import Slide from 'vue-carousel/src/Slide.vue'
18+
19+
@Component({
20+
components: {
21+
Carousel,
22+
Slide
23+
}
24+
})
25+
export default class extends Vue {
26+
public loopCounter: number = 10
27+
public clickCounter: string = ''
28+
29+
public handleSlideClick(dataset) {
30+
console.log(dataset.index)
31+
this.clickCounter = dataset.index + ' click!'
32+
}
33+
34+
public head() {
35+
return {
36+
title: 'vue-carousel'
37+
}
38+
}
39+
}
40+
</script>
41+
42+
<style lang="scss">
43+
.VueCarousel-slide {
44+
position: relative;
45+
background: #42b983;
46+
color: #fff;
47+
font-family: Arial;
48+
font-size: 24px;
49+
text-align: center;
50+
min-height: 100px;
51+
height: 300px;
52+
}
53+
54+
.label {
55+
}
56+
</style>

src/plugins/vue-carousel.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Vue from 'vue'
2+
import VueCarousel from 'vue-carousel'
3+
4+
Vue.use(VueCarousel)

yarn.lock

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12296,6 +12296,15 @@ void-elements@^2.0.1:
1229612296
version "2.0.1"
1229712297
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec"
1229812298

12299+
vue-carousel@^0.18.0:
12300+
version "0.18.0"
12301+
resolved "https://registry.yarnpkg.com/vue-carousel/-/vue-carousel-0.18.0.tgz#478dfcad3abe2ee44c227020b6e60fb8484dc9f1"
12302+
integrity sha512-a2zxh7QJioDxNMguqcuJ7TPbfgK5bGDaAXIia7NWxPAWsEvNE4ZtHgsGu40L5Aha4uyjmNKXvleB14QAXFoKig==
12303+
dependencies:
12304+
global "^4.3.2"
12305+
regenerator-runtime "^0.12.1"
12306+
vue "^2.5.17"
12307+
1229912308
1230012309
version "7.0.1"
1230112310
resolved "https://registry.yarnpkg.com/vue-class-component/-/vue-class-component-7.0.1.tgz#7af2225c600667c7042b60712eefdf41dfc6de63"
@@ -12420,7 +12429,7 @@ vue@^2.0.0:
1242012429
version "2.6.8"
1242112430
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.8.tgz#f21cbc536bfc14f7d1d792a137bb12f69e60ea91"
1242212431

12423-
vue@^2.6.10:
12432+
vue@^2.5.17, vue@^2.6.10:
1242412433
version "2.6.10"
1242512434
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.10.tgz#a72b1a42a4d82a721ea438d1b6bf55e66195c637"
1242612435
integrity sha512-ImThpeNU9HbdZL3utgMCq0oiMzAkt1mcgy3/E6zWC/G6AaQoeuFdsl9nDhTDU3X1R6FK7nsIUuRACVcjI+A2GQ==

0 commit comments

Comments
 (0)