How to use element-ui - 10 common examples

To help you get started, we’ve selected a few element-ui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github d2-projects / d2-admin-start-kit / src / store / modules / d2admin / modules / account.js View on Github external
*/
      async function logout () {
        // 删除cookie
        util.cookies.remove('token')
        util.cookies.remove('uuid')
        // 清空 vuex 用户信息
        await dispatch('d2admin/user/set', {}, { root: true })
        // 跳转路由
        router.push({
          name: 'login'
        })
      }
      // 判断是否需要确认
      if (confirm) {
        commit('d2admin/gray/set', true, { root: true })
        MessageBox.confirm('确定要注销当前用户吗', '注销用户', {
          type: 'warning'
        })
          .then(() => {
            commit('d2admin/gray/set', false, { root: true })
            logout()
          })
          .catch(() => {
            commit('d2admin/gray/set', false, { root: true })
            Message({
              message: '取消注销操作'
            })
          })
      } else {
        logout()
      }
    },
github zcbin / minimall / minimall-admin-vue / src / utils / request.js View on Github external
response => {
    const res = response.data;
    console.log("res=="+JSON.stringify(res));
    // if the custom code is not 20000, it is judged as an error.
    if (res.errno !== 0) {
      Message({
        message: res.errmsg || 'Error',
        type: 'error',
        duration: 5 * 1000
      })

      // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
      if (res.code === 501) {
        // to re-login
        MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {
          confirmButtonText: 'Re-Login',
          cancelButtonText: 'Cancel',
          type: 'warning'
        }).then(() => {
          store.dispatch('user/resetToken').then(() => {
            location.reload()
          })
        })
      }
      return Promise.reject(new Error(res.errmsg || 'Error'))
    } else {
      return res
    }
  },
  error => {
github imyanger / yblog / yanger-app / static / js / http.js View on Github external
MessageBox.alert(response.data.msg, '提示', {
                confirmButtonText: '确定',
                callback: action => {
                    router.push({
                        path: "/back/login",
                        querry: {
                            // 从哪个页面跳转
                            redirect: router.currentRoute.fullPath
                        } 
                    })
                }
            });
        }
        // 后台请求失败
        else if(response.data.status === 1){
            MessageBox.alert(response.data.msg, '提示', {
                confirmButtonText: '确定',
                callback: action => { }
            });
            return Promise.reject(response.data.msg);
        }
        //有token则更新token
        else if(response.data.token) {
            if(response.config.url.indexOf("/blog/") > -1) {
                localStorage.setItem('$token', response.data.token);
            } else {
                localStorage.setItem('$back-token', response.data.token);
            }
        }
        console.log(response.data);
        return response;
    },
github Hzy0913 / my-blog / admin / src / component / PublicArticleEdit.vue View on Github external
respone => {
                Message.success('文章发布成功')
            // 如果文章信息保存成功就给父组件派发一个事件通知它刷新文章列表
            self.$emit('saveArticleInformation')
        },
            respone => Message.error('文章发布失败')
github Hzy0913 / my-blog / admin / src / component / ArticleEdit.vue View on Github external
respone => {
                    this.loading=false;
                Message.success('文章保存成功')

                // 如果文章信息保存成功就给父组件派发一个事件通知它刷新文章列表
                self.$emit('saveArticleInformation')
            },
                respone => {
github ALiangLiang / Counter-for-Messenger / src / tab / index.js View on Github external
import SocialSharing from 'vue-social-sharing'
import Icon from 'vue-awesome/components/Icon'

const _queue = new Queue(10, Infinity)

// Alias i18n function.
const __ = chrome.i18n.getMessage
Vue.prototype.__ = __

// Change docuemnt title manually. Coz title is assign on build stage.
document.title = __('extName')

Vue.config.productionTip = false

const mainLangName = chrome.i18n.getUILanguage().split('-')[0]
locale.use((mainLangName === 'zh') ? zhLocale : enLocale)

// Import element-ui components.
const elements = [
  Slider,
  Loading,
  Button,
  Table,
  TableColumn,
  Tag,
  Tooltip,
  DatePicker,
  Pagination,
  Switch,
  Container,
  Menu,
  MenuItem,
github ALiangLiang / Counter-for-Messenger / src / options / index.js View on Github external
import Vue from 'vue'
import { Form, FormItem, Switch } from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-TW'
import locale from 'element-ui/lib/locale'
import root from './root.vue'

Vue.config.productionTip = false

const mainLangName = chrome.i18n.getUILanguage().split('-')[0]
locale.use((mainLangName === 'zh') ? zhLocale : enLocale)

Vue.use(Form, { locale })
Vue.use(FormItem, { locale })
Vue.use(Switch, { locale })

/* eslint-disable no-new */
new Vue({
  el: '#root',
  render: h => h(root)
})
github ElemeFE / element / packages / popover / src / main.vue View on Github external
reference.setAttribute('tabindex', this.tabindex); // tab序列
      popper.setAttribute('tabindex', 0);

      if (this.trigger !== 'click') {
        on(reference, 'focusin', () => {
          this.handleFocus();
          const instance = reference.__vue__;
          if (instance && typeof instance.focus === 'function') {
            instance.focus();
          }
        });
        on(popper, 'focusin', this.handleFocus);
        on(reference, 'focusout', this.handleBlur);
        on(popper, 'focusout', this.handleBlur);
      }
      on(reference, 'keydown', this.handleKeydown);
      on(reference, 'click', this.handleClick);
    }
    if (this.trigger === 'click') {
      on(reference, 'click', this.doToggle);
      on(document, 'click', this.handleDocumentClick);
    } else if (this.trigger === 'hover') {
      on(reference, 'mouseenter', this.handleMouseEnter);
      on(popper, 'mouseenter', this.handleMouseEnter);
      on(reference, 'mouseleave', this.handleMouseLeave);
      on(popper, 'mouseleave', this.handleMouseLeave);
    } else if (this.trigger === 'focus') {
      if (this.tabindex < 0) {
        console.warn('[Element Warn][Popover]a negative taindex means that the element cannot be focused by tab key');
      }
      if (reference.querySelector('input, textarea')) {
        on(reference, 'focusin', this.doShow);
github ElemeFE / element / packages / popover / src / main.vue View on Github external
addClass(reference, 'el-popover__reference');
      reference.setAttribute('aria-describedby', this.tooltipId);
      reference.setAttribute('tabindex', this.tabindex); // tab序列
      popper.setAttribute('tabindex', 0);

      if (this.trigger !== 'click') {
        on(reference, 'focusin', () => {
          this.handleFocus();
          const instance = reference.__vue__;
          if (instance && typeof instance.focus === 'function') {
            instance.focus();
          }
        });
        on(popper, 'focusin', this.handleFocus);
        on(reference, 'focusout', this.handleBlur);
        on(popper, 'focusout', this.handleBlur);
      }
      on(reference, 'keydown', this.handleKeydown);
      on(reference, 'click', this.handleClick);
    }
    if (this.trigger === 'click') {
      on(reference, 'click', this.doToggle);
      on(document, 'click', this.handleDocumentClick);
    } else if (this.trigger === 'hover') {
      on(reference, 'mouseenter', this.handleMouseEnter);
      on(popper, 'mouseenter', this.handleMouseEnter);
      on(reference, 'mouseleave', this.handleMouseLeave);
      on(popper, 'mouseleave', this.handleMouseLeave);
    } else if (this.trigger === 'focus') {
      if (this.tabindex < 0) {
        console.warn('[Element Warn][Popover]a negative taindex means that the element cannot be focused by tab key');
      }
github SmallRuralDog / laravel-vue-admin / resources / js / util / axios.js View on Github external
({ response }) => {
        //console.log(response.status);
        // 对响应错误做点什么
        switch (response.status) {
            case 404:
                Notification.error({
                    title: "请求页面不存在",
                    desc: response.data.message
                });
                router.replace('/404')
                break;
            default:
                Notification.error({
                    title: "请求错误",
                    desc: response.data.message
                });
                break;
        }

        return Promise.reject(response);
    }
);