You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.5 KiB
82 lines
1.5 KiB
<template>
|
|
<view>
|
|
<image v-if="selectedItem" :src="selectedItem.image" class="random-image" mode=""></image>
|
|
<view v-if="selectedItem" class="random-image-name">
|
|
{{selectedItem.name}}
|
|
</view>
|
|
<view v-if="selectedItem" class="random-image-desc">
|
|
{{selectedItem.desc}}
|
|
</view>
|
|
<MusicControl />
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import MusicControl from '@/components/MusicControl.vue'
|
|
|
|
export default {
|
|
components: {
|
|
MusicControl
|
|
},
|
|
props: {
|
|
images: {
|
|
type: Array,
|
|
required: true
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
selectedItem: null
|
|
}
|
|
},
|
|
mounted() {
|
|
this.selectRandomImage()
|
|
},
|
|
methods: {
|
|
selectRandomImage() {
|
|
if (this.images && this.images.length > 0) {
|
|
const randomIndex = Math.floor(Math.random() * this.images.length)
|
|
this.selectedItem = this.images[randomIndex]
|
|
|
|
console.log(this.selectedItem)
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
exposedMethods() {
|
|
return {
|
|
selectRandomImage: this.selectRandomImage,
|
|
selectedItem: this.selectedItem
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.random-image {
|
|
width: 100vw;
|
|
height: 100vh;
|
|
}
|
|
|
|
.random-image-name {
|
|
position: absolute;
|
|
bottom: 30%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
color: #ffffff;
|
|
font-size: 52rpx;
|
|
}
|
|
|
|
.random-image-desc {
|
|
white-space: nowrap;
|
|
position: absolute;
|
|
bottom: 25%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
color: #ffffff;
|
|
font-size: 24rpx;
|
|
font-weight: 300;
|
|
opacity: .8;
|
|
}
|
|
</style>
|