方式1
<template><div :class="$style.logo"></div></template><style module>.logo{width: 100px;}</style>
方式2
<template><div :class="classes.logo"></div></template><script>import classes from 'index.modules.css';</script>
// index.modules.css.logo{width: 100px;}
以上两种方式都可以实现css的模块化。
使用scss
安装依赖,其他什么都不用配置。
npm install -D sass
可以直接使用:
<template></template><script scoped lang='scss'>$link-color: 'blue';a{color: $link-color;}</script>
使用 autoprefixer
安装依赖。
npm install -D autoprefixer
新增配置文件:
postcss.config.js
module.exports = {plugins: [require('autoprefixer')]}
