第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在模態(tài)中顯示v-for中點(diǎn)擊元素的vue數(shù)據(jù)

如何在模態(tài)中顯示v-for中點(diǎn)擊元素的vue數(shù)據(jù)

慕斯王 2023-10-14 15:40:29
這就是我的 json 的樣子。我以 v-for 格式顯示其中一堆,并且可以單擊其中一個(gè)。我想顯示我在模式中單擊的元素的數(shù)據(jù)。[{        "id": 1,        "companyName": "test",        "image": "https://mmelektronik.com.pl/wp-content/uploads/2017/10/Insert-logo.jpg.png",        "location": "Warsaw",        "salary": "10000",        "skill": "Junior",        "tags": "test",        "jobDescription": "test",        "title": "UI Designer"    }]    Now I want to access only jobDescription and display it in the modal.b-modal(hide-footer="", :id="id")      template(#modal-title="")        | Information      .d-block.text-center        p {{ want the jobDescription here }}        b-button(variant="primary") Apply這就是我打開模式的方式。  openModal(item) {      this.offer = item;      this.$bvModal.show(this.id);    }成分  b-container    b-card.joblist__post.mt-2(      v-for="offer in filteredOffers",      :id="id"      :key="offer.id",      @click="openModal"    )      .d-flex        .joblist.d-flex.w-100          .joblist__info.d-flex.align-items-center            .company-logo.d-flex.align-items-center.mr-3              b-img.logo(:src="offer.image")            .joblist-name.d-flex.flex-column.text-left              h5.mb-0.font-weight-bold {{ offer.title }}              .located.d-flex.align-items-center.mt-2.justify-content-start                b-icon.mr-2(icon="geo-alt-fill")                p.m-0.text-secondary.joblist-span {{ offer.location }}                b-icon.mx-2(icon="person-fill")                p.m-0.text-secondary.joblist-span {{ offer.companyName }}                b-icon.mx-2(icon="bar-chart-fill")         b-modal(hide-footer="", :id="id")      template(#modal-title="")        | Information       .d-block.text-center        p {{offer.jobDescription}}      b-button(variant="primary") Okexport default {  data() {    return {      search: "",    };  },
查看完整描述

2 回答

?
倚天杖

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊

您可以采用以下簡(jiǎn)單方法。數(shù)據(jù)中有一個(gè)selectedItem屬性,如下所示:


data: {

   return {

      selectedItem: {}

   }

}

并在元素上添加單擊,如下所示,將單擊的對(duì)象分配給 selectedItem:


<button v-for="(e, i) in whateverDataArray" :key="i" @click="selectedItem=e">

    {{ e.companyName }}

</button>

然后只需將 selectedItem 作為道具傳遞給模態(tài),這樣當(dāng)模態(tài)出現(xiàn)時(shí),它將顯示被單擊的道具selectedItem!


編輯:在您的情況下,您也應(yīng)該從 for 循環(huán)中刪除模態(tài)。此外,您不需要將selectedItemas 屬性傳遞給模式,因?yàn)槟梢栽L問selectedItem.


查看完整回答
反對(duì) 回復(fù) 2023-10-14
?
MMTTMM

TA貢獻(xiàn)1869條經(jīng)驗(yàn) 獲得超4個(gè)贊

將您的更改data為:


data() {

  return {

    search: "",

    offer: null

  };

},

在您的模板中使用以下內(nèi)容:


p {{ offer.jobDescription }}

并將click處理程序更改為:


@click="openModal(offer)"

offer一旦首先在數(shù)據(jù)中定義并通過點(diǎn)擊傳遞,來自評(píng)論的建議就應(yīng)該起作用。你確實(shí)開始o(jì)ffer行動(dòng)了openModal。


你的模態(tài)不應(yīng)該在里面v-for。把它拿出來并硬編碼一個(gè)id:


b-modal(hide-footer="", id="offerModal")

打開它:


this.$bvModal.show('offerModal');


查看完整回答
反對(duì) 回復(fù) 2023-10-14
  • 2 回答
  • 0 關(guān)注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)