Answer the question
In order to leave comments, you need to log in
How to find by element by vue object key?
Hello, I'm trying to get an object by key, the key is $route.params.id, as I understand it, it doesn't work because params id is a string.
Below is my code:
<template>
<div class="center-loader">
<div v-if="requests && $route.params.id" class="gallery">
{{requests.id}}
<!-- <div class="flexbin flexbin-margin">
<a v-for="(gallery, i) in requests.portal.photos" :key="i" @click="navigate(i, gallery.tags)">
<img v-if="gallery.image" v-lazy="{src: `/images/${gallery.image}`}" class="el" height="400"
alt="image">
</a>
</div>-->
</div>
</div>
</template>
<script>
import database from '@/assets/database.json'
export default {
data(){
return {
requests: database,
}
},
beforeCreate() {
localStorage.clear()
},
methods: {
navigate(id, tag){
this.$router.push(`/gallery/?id=${tag}_${id+1}`)
setTimeout(() => {
location.reload()
}, 1500)
},
},
computed: {
id () {
return this.$route.params.id
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question