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

antDesign 自定義分頁樣式的實(shí)現(xiàn)代碼

 更新時(shí)間:2022年10月21日 15:42:57   作者:周家大小姐.  
這篇文章主要介紹了antDesign 自定義分頁樣式的實(shí)現(xiàn)代碼,這里用到了自定義指令,如果大家用不到可以按照自己的實(shí)際效果開發(fā),本文通過實(shí)例代碼給大家詳細(xì)講解,需要的朋友可以參考下

原圖

 

設(shè)計(jì)要的效果圖

上代碼

這里用到了自定義指令,如果大家用不到可以安自己的實(shí)際效果開發(fā)

 創(chuàng)建directive/index.js頁面用于把所有自定義指令可以一次引入

/*
 * @Author: 周云芳
 * @Date: 2022-06-28 15:21:41
 * @LastEditors: 周云芳 164591357@qq.com
 * @LastEditTime: 2022-10-21 14:26:58
 * @Description: 用于自動(dòng)注冊(cè)全局自定義指令
 * 使用規(guī)則:
 * 根據(jù)導(dǎo)出的name在頁面使用如directives對(duì)象中的name為a-pagination,頁面使用:v-a-pagination
 */
const requireDirective = require.context('./', true, /\.js$/)
// 自定義指令
let directives = {}
requireDirective.keys().map(file => {
  // console.log('file', file)
  const name = removerLastIndex(file)
  console.log('name', name)
  if (name) {
    directives = {
      ...directives,
      [name]: requireDirective(file).default
    }
  }
 
  return false
})
function removerLastIndex(str) {
  const start = str.substring(2, str.length) // 去除路徑中的./ start=el-drag-dialog/index.js
  // str = login/index
  // 獲取最后一個(gè)/的索引
  const index = start.lastIndexOf('/')
  // 獲取最后一個(gè)/后面的值
  const val = start.substring(index + 1, start.length)
  // 判斷是不是index結(jié)尾
  if (val === 'index.js') {
    return start.substring(index, -1)
  }
  return str
}
 
export default {
  install(Vue) {
    Object.keys(directives).forEach(key => {
      Vue.directive(key, directives[key])
    })
  }
}

創(chuàng)建分頁指令頁面在directive文件夾下建a-pagination這文件夾下創(chuàng)建兩個(gè)文件index.css,index.js

index.js寫業(yè)務(wù)邏輯

/*
 * @Author: 周云芳
 * @Date: 2022-07-19 09:12:39
 * @LastEditors: 周云芳 164591357@qq.com
 * @LastEditTime: 2022-10-21 15:05:49
 * @Description:設(shè)置分頁為左右布局 指令使用 v-el-pagination
 */
import './index.css'
export default {
  inserted: (el, binding) => {
    setTimeout(() => {
      // 把分頁條數(shù)放入總條數(shù)后
      const options = el.getElementsByClassName('ant-pagination-options')[0]
      const sizeChange = options.getElementsByClassName(
        'ant-pagination-options-size-changer'
      )[0] // 分頁數(shù)
      const prev = el.getElementsByClassName('ant-pagination-prev')[0]
      //   // 創(chuàng)建兩個(gè)左右div
      const liDom = document.createElement('li')
      liDom.className = 'size-change-li'
      //   RDiv.className = 'right-div'
      liDom.appendChild(sizeChange)
      el.insertBefore(liDom, prev) // 在上一頁前插入節(jié)點(diǎn)
    }, 100)
  }
}

效果:

index.css 進(jìn)行樣式調(diào)整

.size-change-li {
    display: inline-block;
}
.ant-pagination-prev .ant-pagination-item-link,
 .ant-pagination-next .ant-pagination-item-link,
.ant-pagination-item {
    border: none;
}
 
.ant-pagination-item {
    font-family: 'PingFang SC';
font-style: normal;
font-weight: 400;
font-size: 14px;
}
 
.ant-pagination-item-active {
    background: #3296FA;
    border-radius: 4px;
}
 
.ant-pagination-item-active a,.ant-pagination-item-active:focus a, .ant-pagination-item-active:hover a{
    color: #FFFFFF;
}

最后效果

最后記得全局自定義指令要在main.js引入

import Directive from '@/directive'
Vue.use(Directive)

頁面使用指令  v-a-pagination

 <a-pagination v-a-pagination show-quick-jumper  show-size-changer  :total="total" :show-total="total => `總共 ${total} 條`"  @change="onChange" />

到此這篇關(guān)于antDesign 自定義分頁樣式的文章就介紹到這了,更多相關(guān)antDesign 自定義分頁內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

通州市| 湛江市| 全椒县| 隆德县| 滨州市| 遂宁市| 屏山县| 博湖县| 阜宁县| 旌德县| 丹凤县| 维西| 抚顺县| 瓦房店市| 凤阳县| 西城区| 黑龙江省| 上饶市| 色达县| 大足县| 罗定市| 池州市| 桦南县| 乐东| 大关县| 天等县| 溧水县| 台南市| 凤冈县| 蒙阴县| 石泉县| 平度市| 达拉特旗| 灵石县| 临夏市| 保康县| 时尚| 凤庆县| 旌德县| 安化县| 观塘区|