報錯如下:
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也引進(jìn)來,然后使用組件方式。博主用了按需引入的,其他組件都可以,部分反饋組件不能用
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)",
});
// 請求接口數(shù)據(jù)
cameraChecProgress({ type })
.then((res) => {
loading.close();
requestDatas = res.data; // 后端返回的數(shù)據(jù)
state.paingAttr.total = requestDatas.length; // 總條數(shù)
state.paingAttr.page = 1; // 第幾頁
toPaging(); // 分頁
})
.catch(() => {
requestDatas = [];
state.listDatas = [];
state.paingAttr.total = 0;
state.paingAttr.page = 1; // 第幾頁
loading.close();
});
};
2、更新按需引入工具(推薦)
使用命令行更新按需引入包,安裝完成后,需要重新啟動項(xiàng)目
npm install unplugin-auto-import@latest unplugin-vue-components@latest --save-dev
樓主之前用了
更新后調(diào)整為
?文章來源:http://www.zghlxwxcb.cn/news/detail-597879.html
v-loading等反饋組件就可以按需引入了?文章來源地址http://www.zghlxwxcb.cn/news/detail-597879.html
到了這里,關(guān)于element plus 使用v-loading報錯解決Can‘t resolve ‘element-plus/es/components/loading-directive/style/index‘的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!