1๐
<style>
tags are automaticly stripped when compiling. Luckily tmorehouse offers a solution by using Vueโs <component>
<template>
<div>
<component is="style">
.foo[data-id="{{ uniqueId }}"] {
color: {{ color }};
}
.foo[data-id="{{ uniqueId }}"] .bar {
text-align: {{ align }}
}
</component>
<div class="foo" :id="id" :data-id="uniqueId">
<div class="bar">
</div>
</div>
</div>
</template>
<script>
export default {
props: {
id: {
type: String,
default: null
}
},
computed: {
uniqueId() {
// Note: this._uid is not considered SSR safe though, so you
// may want to use some other ID/UUID generator that will
// generate the same ID server side and client side. Or just
// ensure you always provide a unique ID to the `id` prop
return this.id || this._uid;
},
color() {
return someCondition ? 'red' : '#000';
},
align() {
return someCondition ? 'left' : 'right';
}
}
}
</script>
Check https://forum.vuejs.org/t/about-using-style-tags-inside-templates/7275/3 for more info
๐คDjurdjen
- [Vuejs]-Fb.db.ref() is not a function โ Firebase realtime with Vuejs
- [Vuejs]-Vue will not communicate with Express through NGINX
Source:stackexchange.com