Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/adam-lynch/vue-any-element

A Vue.js component which allows you to dynamically change the tag of a child element without loads of awkward code
https://github.com/adam-lynch/vue-any-element

vue vuejs

Last synced: about 1 month ago
JSON representation

A Vue.js component which allows you to dynamically change the tag of a child element without loads of awkward code

Awesome Lists containing this project

README

        

# vue-any-element

A Vue.js component which allows you to dynamically change the tag of a child element saving loads of awkward code.

## Installation

You can just copy it ([`AnyElement.js`](AnyElement.js)) into your project (it's really short) or you can install it from npm;

```
npm install vue-any-element
```

## API

It accepts a `tag` prop (e.g. `div`) and whatever inner HTML you pass will be output within that (`div`) element.

## Example

### Input

`Example.vue`:

```html


Hello World!

```

`Example.js`:

```javascript
import AnyElement from 'vue-any-element';

export default {
components: {
AnyElement,
},
data() {
return {
rootTag: 'p',
innerTag: 'span',
}
}
}
```

### Output

```html

Hello World


```

---

Learn more about [render functions](https://vuejs.org/v2/guide/render-function.html).