Element-plus使用中遇到的问题

el-input

复制代码
设置type='number',会出现上下箭头,在全局配置css样式即可解决,在app.vue中的css中加入:
javascript 复制代码
.table-clear-row {
  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button {
    -webkit-appearance: none;
  }

  input[type="number"] {
    -moz-appearance: textfield;
  }

  inpit {
    border: none;
  }
}

.table-clear-row为el-input所在的div类名

el-table实现滚动效果

表格数据是websocket通信获取的数据,首次获取20条数据,以后新增订阅获取一条,新增一条则向上滑动显示最新数据。

javascript 复制代码
const scroll = (tableBody: any) => {
  // 先清除后设置
  cancelAnimationFrame(scrollTimer.value);
  let isScroll = true; //滚动
  const tableDom = tableBody.getElementsByClassName("el-scrollbar__wrap")[0];
  tableDom.scrollTop = tableDom.scrollHeight - curScrollHeight.value - tableDom.clientHeight;
  tableData.value.length <= 300 && (curScrollHeight.value += tableDom.scrollTop);
  scrollTimer.value = requestAnimationFrame(function fn() {
    if (isScroll) {
      tableDom.scrollTop -= 2; //设置滚动速度
      if (tableDom.scrollTop <= 0) {
        isScroll = false;
        if (tableData.value.length > 300) {
          tableData.value.pop();
        }
      }
    }
    requestAnimationFrame(fn);
  })

方法中的tableBody参数为table的ref,tableRef.value.$refs.bodyWrapper

相关推荐
锋行天下6 小时前
公司内网部署大模型的探索之路
前端·人工智能·后端
1024肥宅7 小时前
手写 EventEmitter:深入理解发布订阅模式
前端·javascript·eventbus
EveryPossible8 小时前
google搜索框
vue.js
海市公约9 小时前
HTML网页开发从入门到精通:从标签到表单的完整指南
前端·ide·vscode·程序人生·架构·前端框架·html
行云流水6269 小时前
前端树形结构实现勾选,半勾选,取消勾选。
前端·算法
diudiu_339 小时前
web漏洞--认证缺陷
java·前端·网络
阿珊和她的猫10 小时前
<video>` 和 `<audio>` 标签的常用属性解析
前端
LSL666_10 小时前
4 jQuery、JavaScript 作用域、闭包与 DOM 事件绑定
前端·javascript·html
yinuo10 小时前
前端跨页面通讯终极指南⑤:window.name 用法全解析
前端
小飞侠在吗10 小时前
vue computed 和 watch
前端·javascript·vue.js