How to access SASS variables in script?



  • Hi folks,
    is it possible to access a variable defined in the style part of a Vue Component in its script.
    Let’s say I have:

    <style lang="sass">
    $one: #f80939
    ...
    </style>
    

    Could I somehow do this (in the same file):

    <script>
    export default {
      methods: {
        someMethod () {
          let color = this.$style.one
          // do something with color 'one' here ...
        }
      }
    }
    </script>
    

    I know there is the css module option in vue:
    https://vue-loader.vuejs.org/guide/css-modules.html#usage

    Is this the way to go?
    I’m not sure how I would configure this in Quasar with SASS and everything.

    Can anyone help?

    Best,
    jym


Log in to reply