Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fl3nkey/vue-conditional-attrs

A Vue.js component for conditional rendering attributes and directives.
https://github.com/fl3nkey/vue-conditional-attrs

Last synced: 2 months ago
JSON representation

A Vue.js component for conditional rendering attributes and directives.

Awesome Lists containing this project

README

        

# vue-conditional-attrs
A Vue.js component for conditional rendering attributes and directives.

## Install
**Via npm** `npm instal vue-conditional-attrs --save`

``` js
import VueConditionalAttrs from 'vue-conditional-attrs';
//OR
var VueConditionalAttrs = require('vue-conditional-attrs');

Vue.use(VueConditionalAttrs);
```

**Via script tag**
``` html

```
## Usage
Once installed you have access to `cn-attrs` component.
``` html

```
### Tag name
Accept tag name or component name.


**Type:** `String`


**Attribute:** `tag`


**Default:** `div`
``` html

```

### Attributes
Accept object of attributes.


**Type:** `Object`


**Attribute:** `attrs`
``` html

```
``` js
//Vue instance
data: function() {
return {
attrs: {
'attribute-name': {
value: /* value */,
if: Boolean
}
}
}
}
//Vue instance
```
OR
``` js
//Vue instance
data: function() {
return {
attrs: {
'attribute-name': Boolean /* or value */
}
}
}
//Vue instance
```

### Directives
Accept object of directives.


**Type:** `Object`


**Attribute:** `directives`
``` html

```
``` js
//Vue instance
data: function() {
return {
directives: {
'directive-name': {
value: /* value */,
if: Boolean
}
}
}
}
//Vue instance
```
OR
``` js
//Vue instance
data: function() {
return {
directives: {
'directive-name': Boolean
}
}
}
//Vue instance
```

### Listeners
Accept object of listeners.


**Type:** `Object`


**Attribute:** `on`
``` html

```
``` js
//Vue instance
data: function() {
return {
listeners: {
'listener-name': { //example: click
event: Function,
if: Boolean
}
}
}
}
//Vue instance
```
OR
``` js
//Vue instance
data: function() {
return {
listeners: {
'listener-name': Function /* or false */
}
}
}
//Vue instance
```