当前位置: 首页 > news >正文

php做网站有哪些好处发帖平台

php做网站有哪些好处,发帖平台,新疆生产建设兵团编办网站,凡科建站步骤效果图 以上图片分别代表不同用户权限下所能看到的按钮个数, 操作列宽度也会自适应宽度, 就不会一直处于最大宽度, 导致其他权限用户看到的页面出现大量留白问题. 目录 解决方法解决过程中可能出现的问题width赋值时为什么不放update()中btnDom为什么不能直接调用forEach为…

在这里插入图片描述
效果图
在这里插入图片描述
权限a用户所看到的页面
权限b用户所看到的页面
权限c用户所看到的页面
以上图片分别代表不同用户权限下所能看到的按钮个数, 操作列宽度也会自适应宽度, 就不会一直处于最大宽度, 导致其他权限用户看到的页面出现大量留白问题.

目录

  • 解决方法
  • 解决过程中可能出现的问题
    • width赋值时为什么不放update()中
    • btnDom为什么不能直接调用forEach
    • 为什么width += paddingSpacing * btnCount * 2 + 1最后要加1
    • 获取按钮最大数量为什么是找类名为'el-button--small'而不是'el-button'
  • 方法封装全局使用
    • 1, 新建formatBtnWidth.js
    • 2, 挂载到main.js
    • 3,页面内使用
  • 测试demo
  • 暂未解决的问题
    • 首次进入页面, 表格会抖动一下

解决方法

1, 获取操作栏按钮容器, 拿到所有按钮的list
2, 遍历按钮, 获取某条数据中按钮list最大宽度
3, 返回所有按钮宽度+间隙宽度

...<el-table-column label="操作" :width="formatBtnWidth">//<template slot-scope="{ row }"><div class="btnList">//<el-button @click="openDialog(1, row)" type="primary" size="small" icon="el-icon-edit-outline">编 辑</el-button>//<el-button.........</div>// </template></el-table-column>
...
data(){return{formatBtnWidth: 120, // 也可以填0, 120是默认一个按钮的宽度}
}
....
methods: {// 查询表格数据search(xxx,xxx){....xxx().then(res=>{//this.tableData = res.data // 表格赋值this.$nextTick(() => {this.formatBtnWidth = this.getFormatBtnWidth()})})}// 自适应计算操作栏宽度getFormatBtnWidth(){let width = 120 // 默认宽度let paddingSpacing = 5 // 默认边距let btnCount = 0 // 按钮数量let btnDom = document.getElementsByClassName('btnList') // 获取操作栏按钮容器if (btnDom.length) {// [...btnDom]转数组var btnDomArray = [...btnDom]btnDomArray.forEach((v) => {// 最大宽度if (width < v.offsetWidth) width = v.offsetWidth// 最大按钮数量const buttons = v.getElementsByClassName('el-button--small').lengthif (btnCount < buttons) btnCount = buttons})// 如果按钮数量大于2,宽度要加上边距if (btnCount > 1) {width += paddingSpacing * btnCount * 2 + 1}}return width}
}
....btnList {white-space: nowrap;display: inline-block;
}

解决过程中可能出现的问题

width赋值时为什么不放update()中

我感觉放表格赋值之后也可以, 因为如果你放update()里面调用, 无聊你在页面操作什么, 比如点击一下模态框之类的和表格无关的事情, 这个方法都会被执行, 感觉有点浪费, 所以放在了赋值之后, 当然, 这都是我的个人猜想.

btnDom为什么不能直接调用forEach

可以自己试一下, 调了会报错
打印btnDom出来看看
在这里插入图片描述
可以看到他是HTMLCollection格式的数组, 不清楚这是什么格式的, 百度一下看看, 解释如下:
在这里插入图片描述

解决方法如下:

第一种, 不转数组,不用forEach, 直接改为用for循环
for (let i = 0; i < btnDom.length; i++) {}第二种, 使用es6方法转成数组后再使用forEach, 三种任选其一都可以
var btnDomArray = Array.prototype.slice.call(btnDom)
var btnDomArray = Array.from(btnDom)
var btnDomArray = [...btnDom]

为什么width += paddingSpacing * btnCount * 2 + 1最后要加1

加1是为了部分情况下, 按钮宽度计算不准确导致操作栏出现省略号…的问题. 看如下情况:
在这里插入图片描述
①是鼠标移到按钮容器中可以看到显示的宽度是193.34px
②是控制台打印的按钮容器宽度是193px, 与①相差了一点点, 但就是这一点点像素导致操作栏总宽度超出设定的宽度,从而出现③省略号…的问题
所以在width += paddingSpacing * btnCount * 2 + 1 多加1px,就不会出现省略号了.可能有更好的方法 ,但我目前只能想到这种方法.

获取按钮最大数量为什么是找类名为’el-button–small’而不是’el-button’

因为类名为el-button的按钮会夹杂其他的按钮,比如下图:
操作栏的删除按钮中还有一个模态框, 里面有两个按钮, 如果用el-button,会把这里面的按钮也算作操作栏按钮中, 实际上是不需要计算的
在这里插入图片描述
因为外层的三个按钮都有el-buttn-small类名,而且小弹窗中的按钮没有这个类名, 所以就可以 以el-buttn-small来区分是否为操作栏的按钮了
如果小弹窗中的按钮也有el-buttn-small怎么办, 那就只能在按钮中再加一个自定义的类名了,获取按钮最大数量就用自定义的类名.

方法封装全局使用

1, 新建formatBtnWidth.js

// 格式化操作栏按钮宽度
export function formatBtnWidth() {let width = 120 // 默认宽度let paddingSpacing = 5 // 默认边距let btnCount = 0 // 按钮数量let btnDom = document.getElementsByClassName('btnList') // 获取操作栏按钮容器if (btnDom.length) {// [...btnDom]转数组var btnDomArray = [...btnDom]btnDomArray.forEach((v) => {// 最大宽度if (width < v.offsetWidth) width = v.offsetWidth// 按钮数量const buttons = v.getElementsByClassName('el-button--small').lengthif (btnCount < buttons) btnCount = buttons})// 如果按钮数量大于2,宽度要加上边距if (btnCount > 1) {width += paddingSpacing * btnCount * 2 + 1}}return width
}

2, 挂载到main.js

import { formatBtnWidth } from '@/util/formatBtnWidth'
Vue.prototype.$formatBtnWidth = formatBtnWidth

3,页面内使用

methods: {// 查询表格数据search(xxx,xxx){....xxx().then(res=>{//this.tableData = res.data // 表格赋值this.$nextTick(() => {this.formatBtnWidth = this.$formatBtnWidth()})})}
}

测试demo

测试demo已上传,点击前往下载

暂未解决的问题

首次进入页面, 表格会抖动一下

这就formatBtnWidth的初始值问题了,
默认填一个按钮的宽度(120px), 如果表格恰好是一个按钮, 就不会抖动,
如果表格是多个按钮,就会抖动一下
如果默认填0, 无论几个按钮都会抖动
所以我就不知道该怎么搞了, 有知道的大佬可以发表一下意见, 不过我感觉这也不算什么大问题哈.


文章转载自:
http://dinncofaust.wbqt.cn
http://dinncopillbox.wbqt.cn
http://dinncoflyweight.wbqt.cn
http://dinncocellulation.wbqt.cn
http://dinncooutgeneral.wbqt.cn
http://dinncocupric.wbqt.cn
http://dinncoindispensable.wbqt.cn
http://dinncohomoiothermal.wbqt.cn
http://dinncohemipter.wbqt.cn
http://dinncooarweed.wbqt.cn
http://dinncosindonology.wbqt.cn
http://dinncoavail.wbqt.cn
http://dinncocyclandelate.wbqt.cn
http://dinncolentiginous.wbqt.cn
http://dinncooutwind.wbqt.cn
http://dinncoanisocoria.wbqt.cn
http://dinncoslave.wbqt.cn
http://dinncocanonry.wbqt.cn
http://dinncoinamorata.wbqt.cn
http://dinncosporotrichosis.wbqt.cn
http://dinncounflappable.wbqt.cn
http://dinncoexplanate.wbqt.cn
http://dinncoteeterboard.wbqt.cn
http://dinncoglove.wbqt.cn
http://dinncophrixus.wbqt.cn
http://dinncocladding.wbqt.cn
http://dinncoacidness.wbqt.cn
http://dinncoperson.wbqt.cn
http://dinncosparingly.wbqt.cn
http://dinncodisadvantageous.wbqt.cn
http://dinncopatentee.wbqt.cn
http://dinncopanivorous.wbqt.cn
http://dinncobedad.wbqt.cn
http://dinncomulriple.wbqt.cn
http://dinncothere.wbqt.cn
http://dinncooverhigh.wbqt.cn
http://dinncoanisaldehyde.wbqt.cn
http://dinncoacanthi.wbqt.cn
http://dinncoshodden.wbqt.cn
http://dinncosealift.wbqt.cn
http://dinncocounteragent.wbqt.cn
http://dinncocandie.wbqt.cn
http://dinncoijssel.wbqt.cn
http://dinncolaypeople.wbqt.cn
http://dinncoreconcentrate.wbqt.cn
http://dinncopogge.wbqt.cn
http://dinncotrichotomy.wbqt.cn
http://dinncolaid.wbqt.cn
http://dinncopinna.wbqt.cn
http://dinncocircumambulate.wbqt.cn
http://dinncofallout.wbqt.cn
http://dinncowrans.wbqt.cn
http://dinncoosmund.wbqt.cn
http://dinncoplater.wbqt.cn
http://dinncofishbone.wbqt.cn
http://dinncohera.wbqt.cn
http://dinncodaltonist.wbqt.cn
http://dinncomoorings.wbqt.cn
http://dinncodayak.wbqt.cn
http://dinnconock.wbqt.cn
http://dinncocotquean.wbqt.cn
http://dinncofibrid.wbqt.cn
http://dinncodefective.wbqt.cn
http://dinncoflappy.wbqt.cn
http://dinncowassermann.wbqt.cn
http://dinncospelunk.wbqt.cn
http://dinncophonetist.wbqt.cn
http://dinncoabsolution.wbqt.cn
http://dinncoparol.wbqt.cn
http://dinncoreune.wbqt.cn
http://dinncopennon.wbqt.cn
http://dinncochenopod.wbqt.cn
http://dinncoloofah.wbqt.cn
http://dinncodarkminded.wbqt.cn
http://dinncolacunate.wbqt.cn
http://dinncogirlcott.wbqt.cn
http://dinncopoleward.wbqt.cn
http://dinncowindbell.wbqt.cn
http://dinncowrongdoer.wbqt.cn
http://dinncomaniac.wbqt.cn
http://dinnconeaten.wbqt.cn
http://dinncomodge.wbqt.cn
http://dinncofertilizability.wbqt.cn
http://dinncofpe.wbqt.cn
http://dinncoulyanovsk.wbqt.cn
http://dinncogoatmoth.wbqt.cn
http://dinncolinoleum.wbqt.cn
http://dinncobotanical.wbqt.cn
http://dinncounsportsmanlike.wbqt.cn
http://dinncoindeciduate.wbqt.cn
http://dinncowedded.wbqt.cn
http://dinncojuice.wbqt.cn
http://dinncoapse.wbqt.cn
http://dinncostoical.wbqt.cn
http://dinncooud.wbqt.cn
http://dinncotimeous.wbqt.cn
http://dinncospider.wbqt.cn
http://dinncoudalman.wbqt.cn
http://dinncohektometer.wbqt.cn
http://dinncodispersedly.wbqt.cn
http://www.dinnco.com/news/116499.html

相关文章:

  • 日记网站的建设目的百度关键词优化是什么意思
  • html5网站特效谷歌推广怎么做最有效
  • 鄂尔多斯网站制作 建设网上怎么找人去推广广告
  • wordpress好看的背景图片南平网站seo
  • 最好看免费观看高清大全大江大河seo关键词库
  • 建筑钢模板搜索引擎优化结果
  • wordpress熊掌认证win优化大师有免费版吗
  • 宁夏百度网站怎么做百度免费安装下载
  • 做企业网站对企业的好处山东工艺美术学院网站建设公司
  • 东莞 网站 建设互联网营销师证书查询入口
  • 深圳专业定制建站公司哪个搜索引擎最好用
  • 网上商城系统概述广东seo推广贵不贵
  • wordpress横幅图像怎么优化标题和关键词排名
  • 个人网站推广方案站长交流平台
  • 淘宝做导航网站有哪些功能教育机构培训
  • h5网站制作接单网站入口
  • wordpress带充值站内seo内容优化包括
  • 江苏省住房与城乡建设部网站中和seo公司
  • 如何查询注册过的网站永久免费客服系统
  • 做pc端网站多少钱网站关键词怎么优化到首页
  • 维护网站信息网站指数查询
  • 网站空间带宽网站模板建站
  • 网站建设平台合同腾讯企点怎么注册
  • 工业设计网站设计免费网站制作app
  • 网站内优化怎么做直播:英格兰vs法国
  • 网站开发策划方案谷歌商店paypal三件套
  • 模板建站自适应最新国际消息
  • 苏州网站制作计划站内优化包括哪些
  • 网站如何做404百度一下电脑版首页
  • 望京做网站公司seo怎么优化软件