@tabianco/vue-inherit-component
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

@tabianco/vue-inherit-component

GitHub Actions npm (scoped with tag) npm

Overrides default behavior of pre-defined Vue2 components.

Note: this library works only with Vue2

Usage

  1. Add this package to your dependencies
$ npm i -S @tabianco/vue-inherit-component
# or
$ yarn add @tabianco/vue-inherit-component
  1. Use in your component .vue file
import { inheritComponent } from '@tabianco/vue-inherit-component'

Full example

A full example creating a component inheriting SomeComponent from an awesome-vue-component-library.

import { inheritComponent } from '@tabianco/vue-inherit-component'

import SomeComponent from 'awesome-vue-component-library'

export default inheritComponent(SomeComponent, {
  computedClass (props) {
    return {
      readonly: props.readonly
    }
  },

  computedProps (props) {
    if (props.readonly) {
      return {
        ...props,
        color: 'gray'
      }
    } else {
      return props
    }
  },

  props: {
    color: {
      type: String
    },

    readonly: {
      type: Boolean
    }
  }
})

License

MIT - Tabian Co.

Readme

Keywords

none

Package Sidebar

Install

npm i @tabianco/vue-inherit-component

Weekly Downloads

8

Version

2.3.0

License

MIT

Unpacked Size

7.67 kB

Total Files

8

Last publish

Collaborators

  • kulikala