Skip to content

Instantly share code, notes, and snippets.

@okbm
Created November 19, 2021 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okbm/13302a57ce3b582bfc0019dffed725c0 to your computer and use it in GitHub Desktop.
Save okbm/13302a57ce3b582bfc0019dffed725c0 to your computer and use it in GitHub Desktop.
@okbm
Copy link
Author

okbm commented Dec 16, 2021

element-uiの全読み込みをやめる
mainでelement-uiを全部のコンポーネント入れてたので部分使用にする
https://element.eleme.io/#/en-US/component/quickstart#on-demand

- import ElementUI from 'element-ui';
- Vue.use(ElementUI, {locale: japanese})
+import {
+  Message,
+  MessageBox,
+} from 'element-ui';
+import locale from 'element-ui/lib/locale';
+import 'element-ui/lib/theme-chalk/index.css';
+import lang from 'element-ui/lib/locale/lang/ja';
+locale.use(lang);
+
+Vue.prototype.$alert = MessageBox.alert;
+Vue.prototype.$confirm = MessageBox.confirm;
+Vue.prototype.$message = Message;

# alertとかは他の画面でいっぱい使ってたのでグローバルに入れた
# 他の画面にはこんな感じで対応
+import { Tabs, TabPane } from 'element-ui';

   components: {
+    'el-tabs': Tabs,
+    'el-tab-pane': TabPane,
   },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment