<template>
<div class="wrap_content page">
<div class="content">
<LeftSide/>
<div class="content_catalog">
<div class="top_block">
<div class="bread">孝芯胁邪褉褘</div>
<div class="grid_buttons">
<div class="grid btn on">
<span></span>
<span></span>
<span></span>
</div>
<div class="list btn">
<span></span>
<span></span>
<span></span>
</div>
</div>
</div>
<div class="description">
<img :src="good.image" alt="">
<h1>{{good.brend}}</h1>
<p>{{good.description}}</p>
</div>
<GoodsGrid/>
</div>
</div>
</div>
</template>
<script>
import GoodsGrid from '~/components/goodsGrid'
import LeftSide from '~/components/leftSide'
export default {
validate ({ params }) {
// Must be a number
return /^\d+$/.test(params.id)
},
// good() {
// return data.goods.filter((good) => String(good.id) === params.id);
// },
layout: 'headerAndFooter',
components: {GoodsGrid,
LeftSide},
data ({params}) {
let goods = [
{
"id": 1,
"title": "小芯褋懈褋泻懈",
"promo": false,
"description": "袗褌褟褕械胁芯 ",
"image": "/img/content/tovar1.png",
"brend": "袗褌褟褕械胁芯",
"brend_id": 2,
"min_price": "99.33",
"rate": 4.5,
"count_rate": 348
},
{
"id": 2,
"title": "小邪褉写械谢褜泻懈",
"promo": false,
"description": "褎褉褍褌芯薪褟薪褟 ",
"image": "/img/sliders/brand8.png",
"brend": "褎褉褍褌芯薪褟薪褟",
"brend_id": 2,
"min_price": "99.33",
"rate": 4.5,
"count_rate": 348
}
];
return {
good: goods.filter((good) => String(good.id) === params.id)
}
}
}
</script>
I try to get element of array goods, And substitute its values depending on the id (dynamically)
Hi @Jussiadev,
1) params is not available in data, you should use this.$route.params.id.
2) you should use find instead of filter for goods.
@alexchopin thanks
Can you provide us a repo to help you?
@alexchopin Everything worked here. But the issue #1463 still does not work. I tried the proposed changes, but it did not help.
Same issue here. Using the this.$route.params.id in created and works if the developer toolbar is open with disable cache. When i don't disable cache, the error consists: Cannot read property 'value' of undefined
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi @Jussiadev,
1)
paramsis not available indata, you should usethis.$route.params.id.2) you should use
findinstead offilterfor goods.