element plus 使用v-loading报错解决Can‘t resolve ‘element-plus/es/components/loading-directive/style/index‘

这篇具有很好参考价值的文章主要介绍了element plus 使用v-loading报错解决Can‘t resolve ‘element-plus/es/components/loading-directive/style/index‘。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

报错如下:

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

楼主之前用了

can't resolve 'element-plus/es/locale,vue3,elementplus,框架搭建,vue3,element plus,element按需引入

更新后调整为

 can't resolve 'element-plus/es/locale,vue3,elementplus,框架搭建,vue3,element plus,element按需引入

v-loading等反馈组件就可以按需引入了 文章来源地址https://www.toymoban.com/news/detail-597879.html

到了这里,关于element plus 使用v-loading报错解决Can‘t resolve ‘element-plus/es/components/loading-directive/style/index‘的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 解决Failed to resolve import “@element-plus/icons-vue“ from “src\views\Home.vue“. Does the file exist?

    一、安装镜像(可选) 使用阿里定制的cnpm命令行工具代替默认的npm,输入以下代码 二、解决报错 1.安装Element-plus 1.1在项目目录下执行: 1.2安装按需引入需要的插件: 1.3安装Element Icon (解决标题所言的报错) 2.配置 2.1在Vite的配置文件中加入如下代码: 2.2执行 cnpm run dev 成功

    2024年02月12日
    浏览(38)
  • Vue自定义指令- v-loading封装

    01-自定义指令 什么是自定义指令? 自定义指令:自己定义的指令,可以 封装一些dom操作 ,扩展额外功能。 1、例如:完成自动聚焦的功能: 自定义指令的两种注册语法: 全局注册-语法:

    2024年02月11日
    浏览(25)
  • Rollup failed to resolve import “element-plus/es/components“ from “node_modules/element-plus/es/inde

    – 今天打包的时候出现了错误 暂不知道出现的原因和原理 解决方法,在vite.config中添加build

    2024年02月12日
    浏览(38)
  • 【vue2第十三章】自定义指令 自定义v-loading指令

    像 v-html,v-if,v-for都是vue内置指令,而我们也可以封装自定义指令,提升编码效率。 什么是自定义指令? 自己定义的一些指令,可以进行一些dom操作,扩展格外的功能。比如让图片懒加载,让input自动聚焦。 自定义指令又分为全局注册和局部注册。 使用方法则是与内置指令

    2024年02月09日
    浏览(32)
  • vue自定义指令v-loading(vue2和vue3)

      1. 目录结构: 2. 代码实现  /directives/loading/loading.vue    loading效果页面(此处使用的antd下面的组件,可自定义) /directives/loading/loading.js (实现loading组件的插入及销毁) /directives/loading/index.js (loading指令的注册) 3. 全局引入(main.js文件) 4. 使用 1. 目录结构 2. 代码实现

    2023年04月23日
    浏览(77)
  • 如何解决 Can‘t resolve ‘axios‘ in....

    在启动项目时,突然报错,提示无法解析axios文件.... 我们只需要从新安装axios 如果报错了 只需要在命令后面加上这些,就可以安装成功了,重新 启动项目即可!!!

    2024年02月14日
    浏览(20)
  • 报错记录:can‘t resolve ‘fs‘ in node_modules,Vue3

     报错详情 : 报错原因 :手欠把body-parser安到前端了 解决方法 :把body-parser删了就行了 另外进行了以下错误尝试: 找资料发现vue2出现这种情况,需要得webpack.config.js里新增 在vue3中,没有webpack.config.js,就在vue.config.js里加 resolve: { fallback: { fs: false } },配置后终端也是不报错

    2024年02月13日
    浏览(37)
  • 前端报错 : Module not found: Error: Can‘t resolve ‘xxx‘ in ‘xxx‘

    Module not found: Error: Can\\\'t resolve \\\'../src/comporents/MyHeader\\\' in \\\'C:Users15718Desktopeightsrc\\\' 模块未找到:错误:无法解决../src/comporents/MyHeader\\\' 在 \\\'C:Users15718Desktopeightsrc\\\' 错误原因是组件引入  App.vue/其他组件 时出错了,仔细检查引入的 文件名大小写及单词拼写是否正确!! ! 我的就是comp

    2024年02月09日
    浏览(34)
  • 【React】next+antd报错:Module not found: Can‘t resolve ‘antd/es/content‘

    Antd + Next手册:https://ant.design/docs/react/use-with-next-cn 根据官方手册进行项目创建 yarn create next-app antd-demo yarn add antd 得到以下环境: Environment Info antd 5.6.4 next 13.4.8 react 18.2.0 安装完依赖后,运行 yarn dev 后浏览 http://localhost:3000 时报错: 终端报错信息: 根据官方GitHub issues检索的

    2024年02月13日
    浏览(51)
  • VUE前端启动报错Module not found: Error: Can‘t resolve ‘sass-loader‘

    这个错误提示通常是由于缺少 sass-loader 包导致的。要解决这个问题,可以尝试以下几种方法: 1、确认项目中是否已安装 sass-loader 包。可以在项目根目录下运行以下命令进行确认: 如果没有显示 sass-loader 包或显示版本号为红色,可能需要先安装 sass-loader 包: 2、确认项目中

    2024年02月12日
    浏览(48)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包