查看“︁Node.js/nuxt/css module”︁的源代码
来自康健生活
←
Node.js/nuxt/css module
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 配置 == 配置文件 {{hc|nuxt.config.js|<syntaxhighlight lang="javascript"> build: { css: { loaderOptions: { css: { localIdentName: '[name]__[local]-[hash:base64:5]', camelCase: true } } }, }</syntaxhighlight>}} 或者 {{hc|nuxt.config.js|<syntaxhighlight lang="javascript"> { loaders:{ cssModules: { localIdentName: '[local]_[hash:base64:5]', modules: true, camelCase: true }, sass: { indentedSyntax: true }, }, }</syntaxhighlight>}} == 使用方法 == === style === <syntaxhighlight lang="html5"> <template> <div :class="$style.authentication"> <!-- logo 模块 --> <div :class="$style.authentication__logo"> <img :class="$style.img" src="~assets/img/logo.png"/> ... </div> </template> <style module lang="scss">@import "./networkAuthorizationAuthentication";</style></syntaxhighlight> === script === <syntaxhighlight lang="html5"> <template> <button :class="{ 'global-button-class-name': true, [styles.button]: true, [styles.mini]: mini }">登录</button> </template> <script> import styles from './button.css' export default { props: { mini: Boolean }, data: () => ({ styles }) } </script></syntaxhighlight> 不足: * 在 data 中传入 styles * 使用 styles.localClassName 导入全局类名 * 和组件的属性值绑定 ==== vue-css-modules ==== <syntaxhighlight lang="html5"> <template> <button class="global-button-class-name" styleName="button :mini"> 登录 </button> </template> <script> import CSSModules from 'vue-css-modules' import styles from './button.css' export default { mixins: [CSSModules(styles)], props: { mini: Boolean } } </script></syntaxhighlight>
此页面嵌入的页面:
模板:Hc
(
查看源代码
)
模板:Hc/style.css
(
查看源代码
)
模板:Meta box
(
查看源代码
)
模板:Warning
(
查看源代码
)
模板:Warning/style.css
(
查看源代码
)
返回
Node.js/nuxt/css module
。
导航菜单
康健生活
搜索
user-page
通知
user-interface-preferences
个人工具
登录
五一
多读书,多运动,多到远处走走,再看看不一样的世界。