4 changed files with 42 additions and 13 deletions
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 306 KiB |
After Width: | Height: | Size: 126 KiB |
@ -1,28 +1,57 @@ |
|||||
<template> |
<template> |
||||
<div id="app"> |
<div id="app"> |
||||
<img alt="Vue logo" src="./assets/logo.png"> |
|
||||
<HelloWorld msg="Welcome to Your Vue.js App"/> |
|
||||
|
<h1>Kolotoč</h1> |
||||
|
<div> |
||||
|
<button v-on:click="index -= 1"><</button> |
||||
|
<button v-on:click="index += 1">></button> |
||||
|
<div> |
||||
|
{{ images[index].src }}<br> |
||||
|
{{ images[index].title }} |
||||
|
</div> |
||||
|
<button v-on:click="index = i" v-for="(img, i) in images" :key="i" :title="img.title" v-bind:class="{active: i == index}"></button> |
||||
|
</div> |
||||
</div> |
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import HelloWorld from './components/HelloWorld.vue' |
|
||||
|
|
||||
export default { |
export default { |
||||
name: 'App', |
name: 'App', |
||||
components: { |
|
||||
HelloWorld |
|
||||
|
data: function() { |
||||
|
return { |
||||
|
index: 0, |
||||
|
images: [ |
||||
|
{ |
||||
|
src: "/img/image_01.jpg", |
||||
|
title: "Obrázek 1" |
||||
|
}, |
||||
|
{ |
||||
|
src: "/img/image_02.jpg", |
||||
|
title: "Obrázek 2" |
||||
|
}, |
||||
|
{ |
||||
|
src: "/img/image_03.jpg", |
||||
|
title: "Obrázek 3" |
||||
|
} |
||||
|
], |
||||
|
} |
||||
|
}, |
||||
|
watch: { |
||||
|
index: function(value) { |
||||
|
let total = this.images.length - 1; |
||||
|
if (value < 0) { |
||||
|
this.index = total; |
||||
|
} |
||||
|
else if (value > total) { |
||||
|
this.index = 0; |
||||
|
} |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
</script> |
</script> |
||||
|
|
||||
<style> |
<style> |
||||
#app { |
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif; |
|
||||
-webkit-font-smoothing: antialiased; |
|
||||
-moz-osx-font-smoothing: grayscale; |
|
||||
text-align: center; |
|
||||
color: #2c3e50; |
|
||||
margin-top: 60px; |
|
||||
} |
|
||||
|
.active { |
||||
|
background-color: green; |
||||
|
} |
||||
</style> |
</style> |
||||
|
Loading…
Reference in new issue