3. 常用Props
props是組件實(shí)例的屬性,也是我們?cè)谑褂胻his.$modal時(shí)需要配置的關(guān)鍵參數(shù)。下面是一些常用的props:
title: modal的標(biāo)題 visible.sync: 控制modal是否可見(jiàn) width: modal的寬度,支持%和px等單位 height: modal的高度,支持%和px等單位 top: modal的距離頂部的距離,只支持px modal: 是否展示遮罩層 center: 是否垂直居中 destroy-on-close: 是否在關(guān)閉時(shí)銷(xiāo)毀組件實(shí)例 show-close: 是否顯示關(guān)閉按鈕 close-on-click-modal: 點(diǎn)擊遮罩層是否可關(guān)閉modal lock-scroll: 是否鎖定背景滾動(dòng) custom-class: 自定義class名稱(chēng)4. 常用Events
events是組件實(shí)例的事件,也是我們?cè)谑褂胻his.$modal時(shí)可以偵聽(tīng)的事件。下面是一些常用的事件:
close: modal關(guān)閉時(shí)觸發(fā) open: modal打開(kāi)時(shí)觸發(fā)五、總結(jié)
本文介紹了如何在vue.js中使用this.$modal,以及它的一些基礎(chǔ)概念、常見(jiàn)應(yīng)用場(chǎng)景、具體使用方法、常用props和events等方面的內(nèi)容。通過(guò)上述的學(xué)習(xí),我們可以快速掌握modal的使用技巧,在實(shí)際項(xiàng)目中靈活運(yùn)用。