扑球哈哈 2023-04-29 00:23 采纳率: 100%
浏览 20
已结题

idea安装element组件报错

问题:
图一

img


图二

img

img


毫无头绪,是npm的问题,还是vue的问题啊,网上搜了好久,无解……害!

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-04-29 02:06
    关注
    • 这有个类似的问题, 你可以参考下: https://ask.csdn.net/questions/7598381
    • 你也可以参考下这篇文章:vue封装组件,类似elementUI组件库打包发布到npm上
    • 除此之外, 这篇博客: vue学习笔记 (vue在idea的结构,idea中执行npm命令和配置环境变量,element-ui安装和使用,avue的安装与使用)中的 (4)示例2: 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
    • 修改App.vue

      <template>
        <div id="app">
          <avue-crud :data="filteredData" v-loadmore="handelLoadmore" :option="option" :data-size="tableData.length"></avue-crud>
        </div>
      </template>
      <script>
      export default {
        data() {
          return {
            tableData: [],
            option:{
              height:300,
              expand:true,
              selection:true,
              selectionFixed:false,
              expandFixed:false,
              menuFixed:false,
              column:[{
                label:'姓名',
                prop:'name',
                width:200,
              },{
                label:'年龄',
                prop:'sex'
              }]
            },
            currentStartIndex: 0,
            currentEndIndex: 20
          };
        },
        directives:{
          loadmore:{
            componentUpdated: function (el, binding, vnode, oldVnode) {
              // 设置默认溢出显示数量
              var spillDataNum = 20;
      
              // 设置隐藏函数
              var timeout = false;
              let setRowDisableNone = function (topNum, showRowNum, binding) {
                if (timeout) {
                  clearTimeout(timeout);
                }
                timeout = setTimeout(() => {
                  binding.value.call(null, topNum, topNum + showRowNum + spillDataNum);
                });
              };
              setTimeout(() => {
                const dataSize = vnode.data.attrs['data-size'];
                const oldDataSize = oldVnode.data.attrs['data-size'];
                if (dataSize === oldDataSize) return;
                const selectWrap = el.querySelector('.el-table__body-wrapper');
                const selectTbody = selectWrap.querySelector('table tbody');
                const selectRow = selectWrap.querySelector('table tr');
                if (!selectRow) {
                  return;
                }
                const rowHeight = selectRow.clientHeight;
                let showRowNum = Math.round(selectWrap.clientHeight / rowHeight);
      
                const createElementTR = document.createElement('tr');
                let createElementTRHeight = (dataSize - showRowNum - spillDataNum) * rowHeight;
                createElementTR.setAttribute('style', `height: ${createElementTRHeight}px;`);
                selectTbody.append(createElementTR);
      
                // 监听滚动后事件
                selectWrap.addEventListener('scroll', function () {
                  let topPx = this.scrollTop - spillDataNum * rowHeight;
                  let topNum = Math.round(topPx / rowHeight);
                  let minTopNum = dataSize - spillDataNum - showRowNum;
                  if (topNum > minTopNum) {
                    topNum = minTopNum;
                  }
                  if (topNum < 0) {
                    topNum = 0;
                    topPx = 0;
                  }
                  selectTbody.setAttribute('style', `transform: translateY(${topPx}px)`);
                  createElementTR.setAttribute('style', `height: ${createElementTRHeight - topPx > 0 ? createElementTRHeight - topPx : 0}px;`);
                  setRowDisableNone(topNum, showRowNum, binding);
                })
              });
            }
          }
        },
        created() {
          this.getTableData();
        },
        computed: {
          filteredData() {
            let list = this.tableData.filter((item, index) => {
              if (index < this.currentStartIndex) {
                return false;
              } else if (index > this.currentEndIndex) {
                return false;
              } else {
                return true;
              }
            });
            return list
          }
        },
        methods: {
          handelLoadmore(currentStartIndex, currentEndIndex) {
            this.currentStartIndex = currentStartIndex;
            this.currentEndIndex = currentEndIndex;
          },
          getTableData() {
            let cont = 0;
            let tableData = [];
            while (cont < 10000) {
              cont = cont + 1;
              let object = {
                name: '王小虎' + cont,
                sex:cont
              }
              tableData.push(object);
            }
            setTimeout(() => {
              this.tableData = tableData;
            }, 0);
          }
        }
      }
      </script>
      

      运行结果:
      在这里插入图片描述

    • 您还可以看一下 徐照兴老师的Vue全家桶从基础入门到进阶项目实战第四篇综合进阶项目篇课程中的 使用element完善系统登录界面设计小节, 巩固相关知识点
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 7月14日
  • 已采纳回答 7月6日
  • 创建了问题 4月29日

悬赏问题

  • ¥15 非科班怎么跑代码?如何导数据和调参
  • ¥15 福州市的全人群死因监测点死亡原因报表
  • ¥15 打开powerpont询问是否安装officeplus不小心点了不安装以后再也不提示是否安装了
  • ¥15 Altair EDEM中生成一个颗粒,并且各个方向没有初始速度
  • ¥15 系统2008r2 装机配置推荐一下
  • ¥500 服务器搭建cisco AnyConnect vpn
  • ¥15 用大厂网站防红自己网站
  • ¥15 悬赏Python-playwright部署在centos7上
  • ¥15 psoc creator软件有没有人能远程安装啊
  • ¥15 快速扫描算法求解Eikonal方程咨询