W
W
wufapexef2018-05-17 23:38:18
JavaScript
wufapexef, 2018-05-17 23:38:18

Is it possible to "feed" the Stylus variable to JS (Vue, webpack)?

The question arose, is it possible to make Stylus variables available to Javascript? I need to inline the style, but doing it manually is inconvenient, the whole essence of the components is lost.
Example.
There is a stylus file. There is a single-file Vue component, likehello.styl
$super-color = #777

<template>
  <h1 :style="'color': superColor">Hello</h1>
</template

require ('hello.styl')
export default {
  data () {
    return {
      superColor: ''
    }
  }
}

How to feed this data to the view superColor?
PS: if you can't use Stylus, then maybe PostCSS? How?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fl3nkey, 2018-05-17
@wufapexef

you can describe variables in JSON , and then include this JSON in a JS file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question