Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "element-ui in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'element-ui' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

*/
      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()
      }
    },
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 => {
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;
    },
respone => {
                Message.success('文章发布成功')
            // 如果文章信息保存成功就给父组件派发一个事件通知它刷新文章列表
            self.$emit('saveArticleInformation')
        },
            respone => Message.error('文章发布失败')
respone => {
                    this.loading=false;
                Message.success('文章保存成功')

                // 如果文章信息保存成功就给父组件派发一个事件通知它刷新文章列表
                self.$emit('saveArticleInformation')
            },
                respone => {
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,
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)
})
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);
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');
      }
({ 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);
    }
);

Is your System Free of Underlying Vulnerabilities?
Find Out Now