$con="";
$MODE="";
$dbhost = "localhost";
$dbuser = "root";
$dbpassword = "";
$database = "name";
$con = new PDO ( "mysql:host=$dbhost;dbname=$database", "$dbuser", "$dbpassword", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$con->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
Я бы предпочел согласиться с @ Andrew1325, который указал, что создание отдельного экземпляра модального диалога и передача выбранных данных может быть лучшим вариантом, например
<div>
<div v-for="(item) in items" :key="item.id">
<b-card
:title="item.title"
:img-src="item.imageUrl"
img-alt="Image"
img-top
tag="article"
style="max-width: 20rem;"
class="mb-2"
>
<b-card-text>{{item.text}}</b-card-text>
<b-button variant="primary" @click="showModal(item)">Show details</b-button>
</b-card>
</div>
<b-modal id="modal1" :title="selectedItem.title">
<img style="max-width: 20rem;" :src="selectedItem.imageUrl"/>
<p class="my-4">{{selectedItem.text}}</p>
</b-modal>
</div>
export default {
data() {
return {
selectedItem: {},
items: [
{
id: 1,
title: "First",
imageUrl : "https://picsum.photos/600/300/?image=23",
text: "Some quick example text to build on the card title and make up the bulk of the card's content"
},
{
id: 2,
imageUrl : "https://picsum.photos/600/300/?image=24",
title: "Second",
text: "Some quick example text to build on the card title and make up the bulk of the card's content"
},
{
id: 3,
imageUrl : "https://picsum.photos/600/300/?image=25",
title: "Third",
text: "Some quick example text to build on the card title and make up the bulk of the card's content"
}
]
};
},
methods: {
showModal(item){
this.selectedItem = item;
this.$root.$emit("bv::show::modal", "modal1");
}
}
};