Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vue use props in style

<template>
    <div id="a" :style="cssVars"></div>
</template>

<script>
export default {
    props: ['color'],
    computed: {
      cssVars () {
        return{
          /* variables you want to pass to css */
          '--color': this.color,
        }
    }
}
<script>

<style scoped>
#a{
    background-color: var(--color);
}
</style>
Comment

PREVIOUS NEXT
Code Example
Javascript :: fetch api cors 
Javascript :: copy to clipboard js 
Javascript :: jquery migrate 
Javascript :: how to sort an array of objects by a property value in javascript 
Javascript :: javascript format rupiah 
Javascript :: javascript get all classes 
Javascript :: vue watch object member 
Javascript :: count duplicate elements in array javascript 
Javascript :: minecraft lang file 
Javascript :: how to go to next line in javascript 
Javascript :: how to test on user reaction discord.js 
Javascript :: usestate with string 
Javascript :: how to submit form using ajax 
Javascript :: altv rpc 
Javascript :: datatable get all selected row data 
Javascript :: how to stop react app in terminal 
Javascript :: compare two arrays and return the difference javascript 
Javascript :: js how to print 
Javascript :: node convert buffer to string 
Javascript :: redux template create react app 
Javascript :: jquery get closest form 
Javascript :: how to reverse number in javascript 
Javascript :: js get certain number of elements from array 
Javascript :: jquery remove link href 
Javascript :: ajax load document ready 
Javascript :: convert response to json javascript 
Javascript :: load base64 image in tab javascript 
Javascript :: width and height in js 
Javascript :: btoa javascript 
Javascript :: javascript array function 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =