I am doing an app where I need to extract the CSS inside the style tag in a single file component in Vue JS.
So I have this basic template:
<template>
<div class="wrapper">
<button class="wrapper__button" @click="sendRequest()" click me></button>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
},
methods: {
sendRequest () {
console.log(document.getElementsByTagName("STYLE")[0].innerHTML)
this.$http.post('http://localhost:3000/users/pdf', 'random string').then((response) => {
console.log(response.data)
})
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
.wrapper__button {
background-color: yellow;
}
</style>
Is there a way I can get with Javascript all the data inside the styles in the vue component?
Thanks, guys
styletag? The compiled one (if usedscopedthey will add[data...]), or which version?? I don't believe this is possible, or even and desired.