Vue4auth

A simple authencation library for Vue.js

Version: 1.0.7 Updated: 07/17/2018

By: hoppernpm License: MIT

Downloads Last 30 Days: 65

Install

npm i vue4auth
yarn add vue4auth

CDNs

bundle.run: https://bundle.run/vue4auth

jsDelivr: https://cdn.jsdelivr.net/npm/vue4auth

unpkg: https://unpkg.com/vue4auth

vue4auth

A simple authencation library for Vue.js

  1. register

    import Vue from 'vue';
    import Auth from 'vue4auth';
    Vue.use(Auth, {
      is: (value) => (['aaa', 'bbb'].includes(value))
    });
  2. function

    To control the element dom exsit or not, for frontend authentication.

  3. three ways to use

  • use global api vm.$auth.is(code)

    function is (code) {
      return this.$auth.is(code);
    }
  • use directive v-auth

    <div>
      <a-component v-auth="'aaa'">ssss</a-component>
      <b-component v-auth.else>dddd</b-component>
    </div>
  • use component auth-panel (recommend)

    <auth-panel code="aaa">
      <a-component>ssss</a-component>
      <b-component slot="else">dddd</b-component>
    </auth-panel>
Categories: Vue js