1.0.4 • Published 7 days ago

vue-objectex v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 days ago

Getting started

This package is an advanced object for vue, can be used as an enum.

  1. Install the package:
npm install --save vue-objectex

Usage

Examples

  1. Use example:
import { ObjectEx } from 'vue-objectex'

const objEx = new ObjectEx([
  // Basic options, define enums
  {
    key: "item1",
    value: 1,
    desc: "Item 1"
  }, {
    key: "item2",
    value: 2,
    desc: "Item 2"
  }, {
    key: "item3",
    value: 3,
    desc: "Item 3"
  }], {
    // Extend funcs
    getDesc(value) {
      let enumOption = this.valueOf(value);
      return !!enumOption ? enumOption.desc : "";
    },
    ...
  }, {
    // Extend props
    basicOptions: {
      get() {
        return this.getOptions();
      }
    }
  });
  1. Extend example:
import { ObjectEx } from 'vue-objectex'

class UserManager extends ObjectEx {
  constructor(options, funcExtensions, defineProps) {
    let innerOptions = [];
    if (Object.typeOf(options) === "array") {
      Object.copy(innerOptions, options);
    }

    let innerFuncExtensions = {
      isInRole(roleName) {
        ...
      }
    };
    if (typeof(funcExtensions) === "object") {
      innerFuncExtensions = {...innerFuncExtensions, ...funcExtensions};
    }

    let innerDefineProps = {
      isAdmin: {
        get() {
          return ...;
        }
      },
      ...
    };
    if (Object.typeOf(defineProps) === "object") {
      innerDefineProps = {...innerDefineProps, ...defineProps};
    }

    super(innerOptions, innerFuncExtensions, innerDefineProps);
  }
}

Change Log

CHANGELOG.md

1.0.4

7 days ago

1.0.3

8 days ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago