最近做業(yè)務(wù)的時(shí)候,發(fā)現(xiàn)產(chǎn)品的原型圖上有一個(gè)彈出框,上面包含了兩個(gè)窗口要進(jìn)行切換。
每個(gè)窗口都有分頁(yè)列表展示、搜索、添加和刪除,感覺(jué)就是兩個(gè)完整的頁(yè)面,如果全寫在一個(gè)頁(yè)面會(huì)很麻煩,還可能會(huì)出現(xiàn)一系列的問(wèn)題,后期改起來(lái)比較麻煩,所以我就準(zhǔn)備分開來(lái)寫這個(gè)窗口,先寫兩個(gè)頁(yè)面,最后看能不能嵌入到彈出框里。
這里插入一下vue的頁(yè)面跳轉(zhuǎn)方法,點(diǎn)擊按鈕直接跳轉(zhuǎn)到另一個(gè)頁(yè)面,這樣可以先調(diào)整單個(gè)頁(yè)面的樣式和功能。
<el-table-column label="字典類型" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type">
<span>{{ scope.row.dictType }}</span>
</router-link>
</template>
</el-table-column>
參數(shù)獲取:
created() {
const dictId = this.$route.params && this.$route.params.dictId;
this.getType(dictId);
this.getTypeList();
},
而且這塊跳轉(zhuǎn)的頁(yè)面也是需要配置路由的,要不然頁(yè)面就會(huì)404:
{
path: '/system/dict-data',
component: Layout,
hidden: true,
permissions: ['system:dict:list'],
children: [
{
path: 'index/:dictId(\\d+)',
component: () => import('@/views/system/dict/data'),
name: 'Data',
meta: { title: '字典數(shù)據(jù)', activeMenu: '/system/dict' }
}
]
},
當(dāng)兩個(gè)頁(yè)面的功能都實(shí)現(xiàn)好了之后,開始在主頁(yè)面添加彈出框,實(shí)現(xiàn)內(nèi)嵌頁(yè)面。
- 屬性變量props: [‘a(chǎn)gentId’],該參數(shù)用于父子組件傳值
- 組件創(chuàng)建即created的時(shí)候,賦值請(qǐng)求后臺(tái)加載數(shù)據(jù)
在父頁(yè)面中引入子頁(yè)面:
添加彈出框,內(nèi)嵌子頁(yè)面
<el-dialog :title="filterTitle" :visible.sync="filterDialogVisible" v-if="filterDialogVisible" width="1100px"
append-to-body>
<el-tabs v-model="filterTabValue" type="border-card" :lazy="true" @tab-click="filterTabClick">
<el-tab-pane label="內(nèi)容1" name="hotel">
<!-- 酒店過(guò)濾頁(yè)面 -->
<HotelFilter :agentId="agentId" v-if="isHotel"></HotelFilter>
</el-tab-pane>
<el-tab-pane label="內(nèi)容2" name="keyword">
<Keyword :agentId="agentId" v-if="isKeyword"></Keyword>
</el-tab-pane>
</el-tabs>
</el-dialog>
父頁(yè)面通過(guò)彈框并將子頁(yè)面通過(guò)引入組件的方式包裹在彈框內(nèi),通過(guò):visible.sync=“filterDialogVisible” v-if="filterDialogVisible"進(jìn)行彈框的展示以及組件的創(chuàng)建和銷毀,并且通過(guò)父子組件傳參的方式切換數(shù)據(jù)。注意這里需要使用v-if以便子組件可以在create()中動(dòng)態(tài)展示數(shù)據(jù)。
同理,tabs切換也是通過(guò)v-if來(lái)控制動(dòng)態(tài)渲染頁(yè)面。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-601945.html
//設(shè)置頁(yè)面
filterRuleAdd(row) {
this.agentId = row.agentId;
this.filterDialogVisible = true;
this.filterTitle = "渠道名稱:" + row.agentName;
this.filterTabValue = "hotel";
this.isHotel = true;
},
//禁用配置切換
filterTabClick() {
if (this.filterTabValue == "hotel") {
this.isHotel = true;
this.isKeyword = false;
} else if (this.filterTabValue == "keyword") {
this.isKeyword = true;
this.isHotel = false;
}
},
參考文檔:https://www.jb51.net/article/267510.htm文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-601945.html
到了這里,關(guān)于vue實(shí)現(xiàn)彈出框內(nèi)嵌頁(yè)面展示,添加tab切換展示實(shí)時(shí)加載的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!