Skip to content

Usage

To use Vuelr, add the <Vuelr> component to your template. The component accepts a code prop, which is the code to render. Add a target element with the id set to the target slot property.

Add any element to edit the code. In the example below, a simple textarea is used. Feel free to use any editor you like.

vue
<template>
  <Vuelr :code="code" v-slot="{ target }">
    <div :id="target" />
    <textarea v-model="code" />
  </Vuelr>
</template>

<script lang="ts">
export default defineComponent({
  setup() {
    return {
      code: ref('<p>Hello world!</p>')
    };
  }
});
</script>
<template>
  <Vuelr :code="code" v-slot="{ target }">
    <div :id="target" />
    <textarea v-model="code" />
  </Vuelr>
</template>

<script lang="ts">
export default defineComponent({
  setup() {
    return {
      code: ref('<p>Hello world!</p>')
    };
  }
});
</script>

Props

NameTypeDefaultDescription
idstringElement id. If not set, a pseudorandom id is generated.
codestringThe code for Vuelr to render.
scopedbooleanfalseIf true, styles are contained to the Vuelr target element, to avoid polluting the global styles.

Slots

Vuelr exposes one slot, the default slot. The following properties are passed to the default slot:

NameTypeDescription
targetstringThe id of the target element.
errorstringThe error message, if any.
iterationnumberThe number of times the code has been rendered.
compiledobjectThe compiled code. Contains properties template, script and style.

Released under the MIT License.