最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue3編寫氣泡對話框組件

 更新時間:2022年08月30日 09:37:33   作者:sonicwater  
這篇文章主要為大家詳細介紹了Vue3編寫氣泡對話框組件,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

Vue3氣泡對話框組件,使用 TypeScript枚舉限定類型,樣式用到了 TailwindCSS

組件代碼

<template>
? <div class="mt-5 mb-5 p-2 bg-white border-solid border-gray-300 border-l border-t border-r border-b border-light-blue-500 rounded-md relative">
? ? <div :class="{
? ? ? 'w-2.5 h-2.5 border-gray-300 bg-white transform absolute': true,
? ? ? 'border-l border-t rotate-45 -top-1.5 left-4': placement === 'top-start',
? ? ? 'border-l border-t rotate-45 -top-1.5 inset-x-2/4 -translate-x-1.5': placement === 'top',
? ? ? 'border-l border-t rotate-45 -top-1.5 right-4': placement === 'top-end',
? ? ? 'border-l border-t -rotate-45 top-4 -left-1.5': placement === 'left-start',
? ? ? 'border-l border-t -rotate-45 inset-y-2/4 -left-1.5 -translate-y-1.5': placement === 'left',
? ? ? 'border-l border-t -rotate-45 bottom-4 -left-1.5': placement === 'left-end',
? ? ? 'border-r border-b rotate-45 -bottom-1.5 left-4': placement === 'bottom-start',
? ? ? 'border-r border-b rotate-45 -bottom-1.5 inset-x-2/4 -translate-x-1.5': placement === 'bottom',
? ? ? 'border-r border-b rotate-45 -bottom-1.5 right-4': placement === 'bottom-end',
? ? ? 'border-r border-b -rotate-45 top-4 -right-1.5': placement === 'right-start',
? ? ? 'border-r border-b -rotate-45 inset-y-2/4 -right-1.5 -translate-y-1.5': placement === 'right',
? ? ? 'border-r border-b -rotate-45 bottom-4 -right-1.5': placement === 'right-end',
? ? }"></div>
? ? <slot></slot>
? </div>
</template>

<script lang="ts">
import {
? defineComponent,
? PropType
} from 'vue';

enum EnumPlacement {
? TopStart = "top-start",
? Top = "top",
? TopEnd = "top-end",
? LeftStart = "left-start",
? Left = "left",
? LeftEnd = "left-end",
? BottomStart = "bottom-start",
? Bottom = "bottom",
? BottomEnd = "bottom-end",
? RightStart = "right-start",
? Right = "right",
? RightEnd = "right-end"
}

export default defineComponent({
? name: 'popover-warpper',
? props: {
? ? placement:{
? ? ? type: String as PropType<EnumPlacement>,
? ? ? default: 'top-start'
? ? }
? }
});
</script>
  • 所有樣式均使用 TailwindCSS。
  • 枚舉類型 EnumPlacement 定義了氣泡對話框的箭頭位置。
  • 組件接收參數(shù) placement,并用 PropType 結合枚舉類型限制該參數(shù)的值。
  • 參數(shù) placement 可以不傳,默認值是 top-start,即箭頭指向上方,位置在左端。

使用組件

<template>
? <PopoverWarpper>
? ? <div class="text-black text-lg">標題</div>
? ? <div class="mt-2">內容內容內容內容</div>
? ? <div class="mt-2">內容內容內容內容</div>
? </PopoverWarpper>
</template>
<script>
import { defineComponent } from 'vue';
import PopoverWarpper from '@/components/PopoverWarpper.vue';
export default defineComponent({
? components:{ PopoverWarpper }
})
</script>

展示效果

給組件傳參 <PopoverWarpper placement=“right-end”> 可以控制箭頭位置。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • Vuex中的getter和mutation的區(qū)別詳解

    Vuex中的getter和mutation的區(qū)別詳解

    在現(xiàn)代前端開發(fā)中,狀態(tài)管理是一個不可忽視的話題,而Vuex作為Vue.js的官方狀態(tài)管理庫,在大型應用中扮演著至關重要的角色,當我們使用Vuex進行狀態(tài)管理時,getter和mutation是兩個重要的概念,在本文中,我們將詳細探討getter和mutation的區(qū)別,需要的朋友可以參考下
    2024-12-12
  • Vue.js+Layer表格數(shù)據(jù)綁定與實現(xiàn)更新的實例

    Vue.js+Layer表格數(shù)據(jù)綁定與實現(xiàn)更新的實例

    下面小編就為大家分享一篇Vue.js+Layer表格數(shù)據(jù)綁定與實現(xiàn)更新的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • Vue.js項目前端多語言方案的思路與實踐

    Vue.js項目前端多語言方案的思路與實踐

    前端的國際化是一個比較常見的需求,但網(wǎng)上關于這一方面的直接可用的方案卻不多,這篇文章主要給大家介紹了關于Vue.js項目前端多語言方案的思路與實踐,需要的朋友可以參考下
    2021-07-07
  • vue實現(xiàn)顯示消息提示框功能

    vue實現(xiàn)顯示消息提示框功能

    這篇文章主要介紹了vue實現(xiàn)顯示消息提示框功能,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • 將vue項目打包成電腦端應用.exe的完整步驟

    將vue項目打包成電腦端應用.exe的完整步驟

    最近接了個小活,其中甲方要求把vue項目打包成exe安裝在windows上,其中有也會出現(xiàn)一些小問題和優(yōu)化,特此記錄,這篇文章主要給大家介紹了關于將vue項目打包成電腦端應用.exe的完整步驟,需要的朋友可以參考下
    2023-10-10
  • vue-router 源碼實現(xiàn)前端路由的兩種方式

    vue-router 源碼實現(xiàn)前端路由的兩種方式

    這篇文章主要介紹了vue-router 源碼實現(xiàn)前端路由的兩種方式,主要介紹Hash 路由和History 路由,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • vue.js 表格分頁ajax 異步加載數(shù)據(jù)

    vue.js 表格分頁ajax 異步加載數(shù)據(jù)

    Vue.js通過簡潔的API提供高效的數(shù)據(jù)綁定和靈活的組件系統(tǒng).這篇文章主要介紹了vue.js 表格分頁ajax 異步加載數(shù)據(jù)的相關資料,需要的朋友可以參考下
    2016-10-10
  • vue3 使用socket的完整代碼

    vue3 使用socket的完整代碼

    這篇文章主要介紹了vue3 使用socket的完整代碼,包括vue3客戶端和服務端的實例講解,本文給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧
    2024-03-03
  • vue與vue-i18n結合實現(xiàn)后臺數(shù)據(jù)的多語言切換方法

    vue與vue-i18n結合實現(xiàn)后臺數(shù)據(jù)的多語言切換方法

    下面小編就為大家分享一篇vue與vue-i18n結合實現(xiàn)后臺數(shù)據(jù)的多語言切換方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • Vue使用Axios庫請求數(shù)據(jù)時跨域問題的解決方法詳解

    Vue使用Axios庫請求數(shù)據(jù)時跨域問題的解決方法詳解

    在 VUE 項目開發(fā)時,遇到個問題,正常設置使用 Axios 庫請求數(shù)據(jù)時,報錯提示跨域問題,那在生產(chǎn)壞境下,該去怎么解決呢?下面小編就來和大家詳細講講
    2024-01-01

最新評論

阆中市| 五华县| 吴旗县| 枣强县| 吉安县| 亳州市| 元谋县| 台南县| 安达市| 开平市| 临江市| 墨竹工卡县| 军事| 恩平市| 洱源县| 稷山县| 宁明县| 海阳市| 封开县| 马边| 四平市| 三明市| 柘城县| 唐海县| 淄博市| 科技| 宁安市| 信宜市| 建始县| 广汉市| 武汉市| 手机| 新蔡县| 潍坊市| 响水县| 衡东县| 嵊泗县| 四子王旗| 宁乡县| 长宁区| 乃东县|