There are to two ways, as I know, to achieve this.
Approach 1
Utilize vue.config.js
configuration, less config can also be replaced with sass:
module.exports = {
css: {
loaderOptions: {
less: {
additionalData: `@import '@/style/common.less';`
}
}
}
}
Approach 2
In your .vue file, make your style looks like this:
<style lang="less">
@import (reference) "../../style/variables.less";
#app {
background: @bgColor;
}
</style>
Note: the (reference)
flag is used to make variables defined in variables.less
take effect. If you don't have variables, @import "../../style/variables.less";
is sufficient to do the trick.
For your reference, you can also take a look at this link:
https://github.com/tjcchen/vue-practice/tree/master/multipage-app