2.3.0 • Published 3 years ago
@tabianco/vue-inherit-component v2.3.0
@tabianco/vue-inherit-component
Overrides default behavior of pre-defined Vue2 components.
Note: this library works only with Vue2
Usage
- Add this package to your dependencies
$ npm i -S @tabianco/vue-inherit-component
# or
$ yarn add @tabianco/vue-inherit-component
- 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.