欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue3 table表格組件的使用

 更新時間:2021年11月15日 11:39:40   作者:久曲鍵  
這篇文章主要介紹了Vue3 table表格組件的使用,文章圍繞table表格組件是如何使用的相關(guān)資料展開詳細內(nèi)容,需要的朋友可以參考一下

一、Ant Design Vue

在大量數(shù)據(jù)需要展示時,我們一般都會以報表的形式展現(xiàn),按照直覺習(xí)慣,肯定使用table表格來展示行列數(shù)據(jù)。

因此,我們要使用Ant Design Vue組件庫中的table組件,來進行數(shù)據(jù)的綁定。

1、官網(wǎng)地址

官網(wǎng)地址:https://2x.antdv.com/components/table-cn#API

2、怎么使用

我們先對電子書管理頁面改造,將布局進行調(diào)整,

示例代碼如下:

<template>
  <a-layout class="layout">
    <a-layout-content
        :style="{ background: '#fff', padding: '24px', minHeight: '280px' }">
      <div class="about">
        <h1>電子書管理頁面</h1>
      </div>
    </a-layout-content>
  </a-layout>

 
</template>

效果如下:

3、將電子書表格進行展示

要做的事:

  • 表格渲染
  • slots: 自定義渲染
  • title: 表頭渲染
  • customRender: 值渲染

示例代碼如下:

<template>
  <a-layout class="layout">
    <a-layout-content
        :style="{ background: '#fff', padding: '24px', minHeight: '280px' }">
      <a-table :columns="columns"
               :data-source="ebooks1"
               :pagination="pagination"
               :loading="loading"
      >
        <template #cover="{ text: cover }">
          <img v-if="cover" :src="cover" alt="avatar"/>
        </template>
        <template #name="{ text: name  }">
          <a>{{ text }}</a>
        </template>
        <template #customTitle>

      <span>
        <smile-outlined/>
        Name
      </span>
          </template>
          <template #action="{ record }">
      <span>
        <a-space size="small">
            <a-button type="primary" @click="edit(record)">
              編輯
            </a-button>
             <a-button type="danger">
                刪除
              </a-button>
          </a-space>
      </span>
          </template>
      </a-table>
    </a-layout-content>
  </a-layout>

</template>
<script lang="ts">
import {SmileOutlined, DownOutlined} from '@ant-design/icons-vue';
import {defineComponent, onMounted, reactive, ref, toRef} from 'vue';
import axios from 'axios';

export default defineComponent({
  name: 'AdminEbook',
  setup() {
    const pagination = {
      onChange: (page: number) => {
        console.log(page);
      },
      pageSize: 3,
    };

    const loading = ref(false);
    const columns = [
      {
        title: '封面',
        dataIndex: 'cover',
        slots: {customRender: 'cover'}
      },
      {
        title: '名稱',
        dataIndex: 'name'
      },
      {
        title: '分類一',
        dataIndex: 'category1Id',
        key: 'category1Id',
      },
      {
        title: '分類二',
        dataIndex: 'category2Id',
        key: 'category2Id',
      },
      {
        title: '文檔數(shù)',
        dataIndex: 'docCount'
      },
      {
        title: '閱讀數(shù)',
        dataIndex: 'viewCount'
      },
      {
        title: '點贊數(shù)',
        dataIndex: 'voteCount'
      },
      {
        title: 'Action',
        key: 'action',
        slots: {customRender: 'action'}
      }
    ];
    //使用ref進行數(shù)據(jù)綁定
    const ebooks = ref();
    // 使用reactive進行數(shù)據(jù)綁定
    const ebooks1 = reactive({books: []})
    onMounted(() => {
      axios.get("/ebook/list?name=").then(response => {
        const data = response.data;
        ebooks.value = data.content;
        ebooks1.books = data.content;
      })
    })
    return {
      pagination,
      loading,
      columns,
      ebooks1: ebooks,
      ebooks2: toRef(ebooks1, "books")
    }
  },
  components: {
    SmileOutlined,
    DownOutlined,
  },
});
</script>
<style scoped>
img {
  width: 50px;
  height: 50px;
}
</style>

實際效果:

二、總結(jié)

對于table組件的使用不是很熟的話,需要不斷去嘗試,簡單說,就是對象屬性的映射。

總體感覺下來,還是進行數(shù)據(jù)綁定后,在進行頁面展示,如不是很清晰,請參考這篇《Vue3 列表界面數(shù)據(jù)展示詳情》文章。

到此這篇關(guān)于Vue3 table表格組件的使用的文章就介紹到這了,更多相關(guān)Vue3 table表格組件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue中slot插槽的參數(shù)匯總及使用方案

    vue中slot插槽的參數(shù)匯總及使用方案

    Vue.js中的插槽(slot)是一種機制,允許你在組件的模板中預(yù)留一些位置,以便父組件可以將任意內(nèi)容插入到這些位置,這使得組件更加靈活和可復(fù)用,本文主要介紹了vue中slot插槽的參數(shù)匯總及使用方案,需要的朋友可以參考下
    2024-03-03
  • Vue2中如何使用全局事件總線實現(xiàn)任意組件間通信

    Vue2中如何使用全局事件總線實現(xiàn)任意組件間通信

    全局事件總線就是一種組件間通信的方式,適用于任意組件間通信,下面這篇文章主要給大家介紹了關(guān)于Vue2中如何使用全局事件總線實現(xiàn)任意組件間通信的相關(guān)資料,需要的朋友可以參考下
    2022-12-12
  • 帶你了解前端的幾種包管理器(npm/pnpm等)

    帶你了解前端的幾種包管理器(npm/pnpm等)

    隨著前端工程化的應(yīng)用越來越廣,插件和包的管理也逐漸衍生出很多的管理器,常見的幾種包管理器如:npm、cnpm、yarn、pnpm,那你知道這些管理器之間有哪些區(qū)別嗎?我們一起來逐個認識下它們
    2023-04-04
  • 詳解Vue組件之間的數(shù)據(jù)通信實例

    詳解Vue組件之間的數(shù)據(jù)通信實例

    本篇文章主要介紹了詳解Vue組件之間的數(shù)據(jù)通信實例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • vue3+vite+移動端webview打包后頁面加載空白問題解決辦法

    vue3+vite+移動端webview打包后頁面加載空白問題解決辦法

    這篇文章主要給大家介紹了關(guān)于vue3+vite+移動端webview打包后頁面加載空白問題的解決辦法,文中通過代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2024-06-06
  • vue-route路由管理的安裝與配置方法

    vue-route路由管理的安裝與配置方法

    這篇文章主要介紹了vue-route路由管理的安裝與配置,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-07-07
  • Vue關(guān)于組件化開發(fā)知識點詳解

    Vue關(guān)于組件化開發(fā)知識點詳解

    在本篇文章里,小編給大家分享的是關(guān)于Vue關(guān)于組件化開發(fā)知識點詳解內(nèi)容,有興趣的朋友們可以學(xué)習(xí)下。
    2020-05-05
  • vue中view-model雙向綁定基礎(chǔ)原理解析

    vue中view-model雙向綁定基礎(chǔ)原理解析

    這篇文章主要介紹了vue中view-model雙向綁定基礎(chǔ)原理,文中給大家介紹了vue雙向綁定的原理總結(jié),本文通過示例代碼給大家介紹的非常詳細,需要的朋友可以參考下
    2022-10-10
  • 如何在vue單頁中重復(fù)引入同一子組件

    如何在vue單頁中重復(fù)引入同一子組件

    這篇文章主要介紹了如何在vue單頁中重復(fù)引入同一子組件問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • 詳解vue-socket.io使用教程與踩坑記錄

    詳解vue-socket.io使用教程與踩坑記錄

    本文主要介紹了vue-socket.io使用教程與踩坑記錄,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-04-04

最新評論