I am venturing into creating my first npm package and am currently working on the package's demo. I want to showcase an example of how to use the component.
However, when I include the component usage within the pre and code tags as shown below:
I encounter the following error:
Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <style>, as they will not be parsed.
Below is the code snippet from my App.vue file:
<template>
<pre>
<code>
<template>
<vlider
:id="'first'"
:vlider-data="slider"
:theme="'theme-dark'"
v-model="inputRange"
@click="vliderClick()"
>
<template> slot="bullet" slot-scope="bullet"
<label>{{ bullet.data.label }}</label>
<i
class="em"
:class="[`em-${bullet.data.extras.icon}`]"
></i>
<a target="_blank" :href="bullet.data.extras.learnMore">Learn more ?</a>
</template>
</vlider>
</template>
<script>
import Vlider from "vlider";
export default {
name: "app",
components: {
Vlider
},
data() {
return {
inputRange: null,
slider: [
{label: "Angry", color: "#ffc300", extras: { icon: 'angry', learnMore: 'http://localhost/'}},
{label: "Expressionless", color: "#ffb0fe", extras: { icon: 'expressionless', learnMore: 'http://localhost/'}},
{label: "Astonished", color: "#ff6bd6", extras: { icon: 'astonished', learnMore: 'http://localhost/'}},
{label: "Confounded", color: "#ff9d76", extras: { icon: 'confounded', learnMore: 'http://localhost/'}},
{label: "Okay?", color: "#51eaea", extras: { icon: 'face_with_raised_eyebrow', learnMore: 'http://localhost/'}},
{label: "Blush", color: "#fb3569", extras: { icon: 'blush', learnMore: 'http://localhost/'}}
]
};
},
watch: {
inputRange() {
console.log(this.inputRange)
}
},
methods: {
vliderClick() {
console.log(`clicked`)
}
}
};
</script>
<style>
import "vlider/src/sass/vlider.scss"
</style>
</code>
</pre>
</template>
<script>
import Vlider from "vlider";
...
</script>
I am hopeful that it will function similarly to a normal tag in HTML. I have attempted to use various code block npm packages, but unfortunately, none have produced the desired outcome. Your suggestions and assistance would be greatly appreciated. Thank you for your help.