首页 > 其他分享 >vue3在tsx 中使用ElLoading 无效 ,初始化eltable 样式加载丢失

vue3在tsx 中使用ElLoading 无效 ,初始化eltable 样式加载丢失

时间:2024-08-18 14:49:18浏览次数:9  
标签:ElLoading eltable app vue3 component plus plugins import

在 plugins 目录下创建 elementPlus/index.ts

import type { App } from "vue";

// 需要全局引入一些组件,如ElScrollbar,不然一些下拉项样式有问题
import { ElLoading, ElScrollbar } from "element-plus";

const plugins = [ElLoading];

const components = [ElScrollbar];

export const setupElementPlus = (app: App<Element>) => {
  plugins.forEach((plugin) => {
    app.use(plugin);
  });

  import("element-plus/dist/index.css");

  components.forEach((component) => {
    app.component(component.name!, component);
  });
};

在main.ts 中 引用

// 引入element-plus
import { setupElementPlus } from "@/plugins/elementPlus";

// 全局注册tsx Element-plus
setupElementPlus(app);

如果觉得有用请给作者点个赞
未经作者同,禁止转载 (QQ群:929412850)

标签:ElLoading,eltable,app,vue3,component,plus,plugins,import
From: https://www.cnblogs.com/wxhwpmdyz/p/18365638

相关文章