Make easier to use CSS custom properties in Vue components
$ npm install --save vue-custom-properties
# or
$ yarn add vue-custom-properties
- Install it into Vue.js.
import Vue from 'vue'
import VueCustomProperties from 'vue-custom-properties'
Vue.use(VueCustomProperties)
- Define
customProperties
option in your components.
export default {
data() {
return {
color: 'red',
size: 12
}
},
customProperties: {
'--base-color': 'color', // --base-color: red;
'--base-size'() {
return this.size + 'px' // --base-size: 12px;
}
}
}
MIT