报错如下:

Failed to compile.

./src/views/detectionSystems/deviceStatusList/index.vue?vue&type=template&id=2de634af&scoped=true (./node_modules/unplugin/dist/webpack/loaders/transform.js??ref--34-0!./node_modules/unplugin/dist/webpack/loaders/transform.js??ref--35-0!./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader-v16/dist??ref--1-1!./src/views/detectionSystems/deviceStatusList/index.vue?vue&type=template&id=2de634af&scoped=true) Module not found: Error: Can't resolve 'element-plus/es/components/loading-directive/style/index' in 'C:\code\SIDS\sids_jg_xuanwumen\src\views\detectionSystems\deviceStatusList'

解决办法:

1、手动引入

必须把css也引进来,然后使用组件方式。博主用了按需引入的,其他组件都可以,部分反馈组件不能用

    import { ElLoading } from "element-plus";
    import "element-plus/es/components/loading/style/index";

    let loading = null; // loading

    const queryData = (type = "camera") => {
      requestDatas = [];
      loading = ElLoading.service({
        lock: true,
        text: "拼命加载中...",
        background: "rgba(0, 0, 0, 0.7)",
      });
      // 请求接口数据
      cameraChecProgress({ type })
        .then((res) => {
          loading.close();
          requestDatas = res.data; // 后端返回的数据
          state.paingAttr.total = requestDatas.length; // 总条数
          state.paingAttr.page = 1; // 第几页
          toPaging(); // 分页
        })
        .catch(() => {
          requestDatas = [];
          state.listDatas = [];
          state.paingAttr.total = 0;
          state.paingAttr.page = 1; // 第几页
          loading.close();
        });
    };

2、更新按需引入工具(推荐

使用命令行更新按需引入包,安装完成后,需要重新启动项目

 npm install unplugin-auto-import@latest unplugin-vue-components@latest --save-dev

楼主之前用了

更新后调整为

 

v-loading等反馈组件就可以按需引入了 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐