uniapp 微信小程序 純js文件中引入自定義modal組件(無需所有頁面手動引入組件)
前言
工具:uniapp
開發(fā)端:微信小程序
其他:uview 2.0
場景:接口請求統(tǒng)一封裝中需要對接口返回token失效的情況做modal顯示,引導用戶退出小程序,我的想法是將modal的默認confirm按鈕替換成小程序自帶的退出方法:
<navigator open-type="exit" target="miniProgram" class="item"></navigator>
這樣用戶點擊確認按鈕就能退出小程序,因此uni.showModel不滿足需求,需要用uview的u-model實現(xiàn),也就是要在js文件中顯示自定義組件。文章來源:http://www.zghlxwxcb.cn/news/detail-487816.html
解決方法
1.自定義組件文件/components/logout-model.vue
文章來源地址http://www.zghlxwxcb.cn/news/detail-487816.html
<template>
<view>
<u-modal ref="modal" title="登錄狀態(tài)失效,請重新登錄" :show="showLogout" :closeOnClickOverlay="false" @close="showLogout = false"
showCancelButton>
<view style="display: flex;align-items: center;justify-content: space-around;"
slot="confirmButton">
<navigator open-type="exit" target="miniProgram"
到了這里,關(guān)于uniapp 微信小程序 純js文件中引入自定義modal組件(無需所有頁面手動引入組件)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!