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

基于uniapp+vue3自定義增強(qiáng)版table表格組件「兼容H5+小程序+App端」

 更新時間:2024年05月18日 15:55:56   作者:xiaoyan2017  
uv3-table:一款基于uniapp+vue3跨端自定義手機(jī)端增強(qiáng)版表格組件,支持固定表頭/列、邊框、斑馬紋、單選/多選,自定義表頭/表體插槽、左右固定列陰影高亮顯示,支持編譯兼容H5+小程序端+App端,H5+小程序+App端,多端運(yùn)行一致

uv3-table:一款基于uniapp+vue3跨端自定義手機(jī)端增強(qiáng)版表格組件。支持固定表頭/列、邊框、斑馬紋、單選/多選,自定義表頭/表體插槽、左右固定列陰影高亮顯示。支持編譯兼容H5+小程序端+App端。

如下圖:H5+小程序+App端,多端運(yùn)行一致。

uv3-table表格插件是最新原創(chuàng)項(xiàng)目uniapp-os后臺管理系統(tǒng)的一個獨(dú)立版組件。

由于在開發(fā)uni-os手機(jī)后臺系統(tǒng)需要用到table表格組件。無奈uniapp官方及插件市場table表格組件無論功能及UI上都不滿足要求,于是自己爆肝一個多日夜開發(fā)了一款全新uniapp+vue3綜合表格組件。

目前該項(xiàng)目已經(jīng)出階段性成果接近尾聲了,相信很快就能和大家見面,到時也會做一些技術(shù)分享,敬請期待!

uv3-table使用示例

將uv3-table組件放到uniapp項(xiàng)目components目錄下,無需在頁面再次引入,即可使用。

基礎(chǔ)用法

<uv3-table :columns="columns" :dataSource="data.list" />

自定義條紋樣式

<uv3-table
    :columns="columns"
    :dataSource="data.list"
    stripe
    stripeColor="#eee"
    padding="5px"
    height="450rpx"
/>

綜合用法(固定表頭/列、自定義插槽內(nèi)容)

<script setup>
    import { ref } from 'vue'
    import Mock from 'mockjs'

    const columns = ref([
        {type: 'selection', align: 'center', width: 80, fixed: true}, // 多選
        {type: 'index', label: 'ID', align: 'center', width: 80, fixed: true}, // 索引序號
        {prop: 'author', label: '作者', align: 'center', width: 120},
        {prop: 'title', label: '標(biāo)題', align: 'left', width: 350},
        {prop: 'image', label: '圖片', align: 'center', width: 120},
        {prop: 'switch', label: '推薦', align: 'center', width: 100},
        {prop: 'tags', label: '標(biāo)簽', align: 'center', width: 100},
        {prop: 'rate', label: '評分', align: 'center', width: 200},
        {prop: 'date', label: '發(fā)布時間', align: 'left', width: 250}, // 時間
        {prop: 'action', label: '操作', align: 'center', width: 150, fixed: 'right'}, // 操作
    ])
    const data = ref(Mock.mock({
        total: 100,
        page: 1,
        pagesize: 10,
        'list|20': [
            {
                id: '@id()',
                author: '@cname()',
                title: '@ctitle(10, 20)',
                image: `//api.yimian.xyz/img?id=@integer(100, 300)`,
                switch: '@boolean()',
                'tags|1': ['admin', 'test', 'dev'],
                rate: '@integer(1, 5)',
                date: '@datetime()',
                color: '@color()',
            }
        ]
    }))
</script>
<uv3-table
    :dataSource="data.list"
    :columns="columns"
    :headerBold="true"
    headerBackground="#ecf5ff"
    stripe
    border
    padding="5px"
    maxHeight="650rpx"
    @rowClick="handleRowClick"
    @select="handleSelect"
>
    <!-- 自定義header插槽內(nèi)容 -->
    <template #headerCell="{ key, col, index }">
        <template v-if="key == 'title'">
            <view >{{col.label}} <input placeholder="搜索" size="small" /></view>
        </template>
        <template v-else-if="key == 'date'">
            <uni-icons type="calendar"></uni-icons> {{col.label}}
        </template>
        <template v-else>{{col.label}}</template>
    </template>
    
    <!-- 自定義body插槽內(nèi)容(由于小程序不支持動態(tài):name插槽,通過key標(biāo)識來自定義表格內(nèi)容) -->
    <template #default="{ key, value, row, col, index }">
        <template v-if="key == 'image'">
            <uv-image :src="value" lazyLoad observeLazyLoad @click="previewImage(value)" />
        </template>
        <template v-else-if="key == 'switch'">
            <switch :checked="value"  />
        </template>
        <template v-else-if="key == 'tags'">
            <uv-tags :text="value" :color="row.color" :borderColor="row.color" plain size="mini" />
        </template>
        <template v-else-if="key == 'rate'">
            <uni-rate :value="value" size="14" readonly />
        </template>
        <template v-else-if="key == 'action'">
            <uni-icons type="compose" color="#00aa7f" @click="handleEdit(row)" />
            <uni-icons type="trash" color="#ff007f"  @click="handleDel(row)" />
        </template>
        <template v-else>{{value}}</template>
    </template>
</uv3-table>

rowClick點(diǎn)擊表格行,會返回該行數(shù)據(jù)。

select單選/多選,會返回表格選中數(shù)據(jù)。

uv3Table編碼實(shí)現(xiàn)

uv3-table表格參數(shù)配置

const props = defineProps({
    // 表格數(shù)據(jù)
    dataSource: {
        type: Array,
        default() {
            return []
        }
    },
    /**
     * @params {string} background 對應(yīng)列背景色
     * @params {string} type 對應(yīng)列類型(多選selection 索引index)
     * @params {string} label 顯示的列標(biāo)題
     * @params {string} prop 對應(yīng)的列字段名
     * @params {string} align 列水平對齊方式(left center right)
     * @params {number|string} width 對應(yīng)列寬度
     * @params {boolean|string} fixed 該列固定到左側(cè)(fixed:true|'left')或右側(cè)(fixed:'right')
     * @params {string} columnStyle 對應(yīng)列自定義樣式
     * @params {string} className/class 表格列的類名className
     */
    columns: {
        type: Array,
        default() {
            return []
        }
    },
    // 表格寬度
    width: { type: [Number, String] },
    // 表格高度
    height: { type: [Number, String] },
    // 表格最大高度
    maxHeight: { type: [Number, String] },
    // 是否為斑馬紋
    stripe: { type: [Boolean, String] },
    // 斑馬紋背景
    stripeColor: { type: String, default: '#fafafa' },
    // 是否帶有邊框
    border: { type: [Boolean, String] },
    // 列寬度(推薦默認(rèn)rpx)
    columnWidth: { type: [Number, String], default: 200 },
    // 單元格間距
    padding: { type: String, default: '5rpx 10rpx' },
    // 是否顯示表頭
    showHeader: { type: [Boolean, String], default: true },
    // 表頭背景色
    headerBackground: { type: String, default: '#ebeef5' },
    // 表頭顏色
    headerColor: { type: String, default: '#333' },
    // 表頭字體加粗
    headerBold: { type: [Boolean, String], default: true },
    // 表格背景色
    background: { type: String, default: '#fff' },
    // 表格顏色
    color: { type: String, default: '#606266' },
    // 空數(shù)據(jù)時顯示的文本內(nèi)容,也可以通過 #empty 設(shè)置
    emptyText: { type: String, default: '暫無數(shù)據(jù)' }
})

模板結(jié)構(gòu)如下

<template>
    <view
        
        ...
    >
        <!-- 表頭 -->
        <view v-if="showHeader"  :>
            <view
                v-for="(col, cindex) in columns"
                :key="cindex"
                
                :
                ...
                @click="handleHeaderClick(col)"
            >
                ...
            </view>
        </view>
        <!-- 表體 -->
        <view >
            ...
        </view>
    </view>
</template>

Props參數(shù)

columns參數(shù)

background 對應(yīng)列背景色 type 對應(yīng)列類型(多選selection 索引index) label 顯示的列標(biāo)題 prop 對應(yīng)的列字段名 align 列水平對齊方式(left center right) width 對應(yīng)列寬度 fixed 該列固定到左側(cè)(fixed:true|‘left’) 或 右側(cè)(fixed:‘right’) columnStyle 對應(yīng)列自定義樣式 className/class 表格列的類名className

事件

@headerClick 點(diǎn)擊表頭 @rowClick 點(diǎn)擊行觸發(fā) @select 多選/單選

自定義插槽

headerCell 自定義表頭內(nèi)容 default 默認(rèn)表體內(nèi)容 empty 無數(shù)據(jù)插槽

希望以上分享對大家有些幫助,開發(fā)不易,一起fighting~~??

到此這篇關(guān)于基于uniapp+vue3自定義增強(qiáng)版table表格組件「兼容H5+小程序+App端」的文章就介紹到這了,更多相關(guān)uniapp+vue3自定義增強(qiáng)版table表格組件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue實(shí)現(xiàn)todo應(yīng)用的示例

    Vue實(shí)現(xiàn)todo應(yīng)用的示例

    這篇文章主要介紹了Vue實(shí)現(xiàn)todo應(yīng)用的示例,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下
    2021-02-02
  • 基于vue開發(fā)微信小程序mpvue-docs跳轉(zhuǎn)頁面功能

    基于vue開發(fā)微信小程序mpvue-docs跳轉(zhuǎn)頁面功能

    這篇文章主要介紹了基于vue寫微信小程序mpvue-docs跳轉(zhuǎn)頁面,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-04-04
  • vue懶加載和子組件懶加載的區(qū)別詳解

    vue懶加載和子組件懶加載的區(qū)別詳解

    這篇文章主要給大家介紹了vue懶加載和子組件懶加載有什么區(qū)別,Vue懶加載指的是對圖片等資源的延遲加載,而子組件懶加載則是指延遲加載組件實(shí)例,文中通過代碼示例給大家講解的非常詳細(xì),需要的朋友可以參考下
    2023-12-12
  • 前端Vue學(xué)習(xí)之購物車項(xiàng)目實(shí)戰(zhàn)記錄

    前端Vue學(xué)習(xí)之購物車項(xiàng)目實(shí)戰(zhàn)記錄

    購物車是電商必備的功能,可以讓用戶一次性購買多個商品,下面這篇文章主要給大家介紹了關(guān)于前端Vue學(xué)習(xí)之購物車項(xiàng)目的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-07-07
  • vue中如何下載文件導(dǎo)出保存到本地

    vue中如何下載文件導(dǎo)出保存到本地

    這篇文章主要介紹了vue中如何下載文件導(dǎo)出保存到本地,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • 基于vue.js實(shí)現(xiàn)無縫滾動的兩種方法

    基于vue.js實(shí)現(xiàn)無縫滾動的兩種方法

    在現(xiàn)代的網(wǎng)頁設(shè)計(jì)中,無縫滾動廣告特效已經(jīng)變得非常流行,這種特效能夠吸引用戶的注意力,同時展示多個廣告內(nèi)容,這篇文章主要介紹了基于vue.js實(shí)現(xiàn)無縫滾動的兩種方法,需要的朋友可以參考下
    2026-02-02
  • vue使用Split封裝通用拖拽滑動分隔面板組件

    vue使用Split封裝通用拖拽滑動分隔面板組件

    這篇文章主要介紹了vue使用Split封裝通用拖拽滑動分隔面板組件,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • vue項(xiàng)目打包自動更新版本號且自動刷新緩存的方法示例

    vue項(xiàng)目打包自動更新版本號且自動刷新緩存的方法示例

    這篇文章主要給大家介紹了關(guān)于vue項(xiàng)目打包自動更新版本號且自動刷新緩存的相關(guān)資料,文中通過代碼及圖文介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用vue具有一定的參考借鑒價值,需要的朋友可以參考下
    2024-11-11
  • vue項(xiàng)目中l(wèi)oadsh庫常用方法說明

    vue項(xiàng)目中l(wèi)oadsh庫常用方法說明

    這篇文章主要介紹了vue項(xiàng)目中l(wèi)oadsh庫常用方法說明,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • Vue3中Vuex的詳細(xì)使用方法

    Vue3中Vuex的詳細(xì)使用方法

    在vue3.x中vuex調(diào)取值在html代碼里可以直接使用vue2.x的方法,但是在js里與vue2.x就有了那么一丟丟的不同,下面這篇文章主要給大家介紹了關(guān)于Vue3中Vuex詳細(xì)使用的相關(guān)資料,需要的朋友可以參考下
    2022-07-07

最新評論

南雄市| 耒阳市| 郧西县| 门源| 天祝| 乳源| 兰溪市| 姜堰市| 龙海市| 全南县| 南岸区| 天峨县| 富源县| 万安县| 永泰县| 丽江市| 南通市| 磐安县| 松江区| 安泽县| 屏山县| 建昌县| 商水县| 疏附县| 西峡县| 石狮市| 和平县| 抚州市| 永靖县| 罗定市| 施甸县| 前郭尔| 永吉县| 临漳县| 澎湖县| 陇南市| 镇坪县| 武功县| 吉首市| 安仁县| 子洲县|