基于angular material theming机制如何修改mat-toolbar的背景色(mat-toolbar,开发技术)

时间:2024-05-02 08:47:26 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

    %E5%9F%BA%E4%BA%8Eangular%C2%A0material%C2%A0theming%E6%9C%BA%E5%88%B6%E5%A6%82%E4%BD%95%E4%BF%AE%E6%94%B9mat-toolbar%E7%9A%84%E8%83%8C%E6%99%AF%E8%89%B2

首先通过 mat-toolbar (以下统一称为 toolbar)的实现源代码 _toolbar-theme.scss 得知背景色来自 theme 中 background palette 的 app-bar

于是通过下面的 scss 代码修改 app-bar 的颜色值

注:第1行代码就是我们想使用的背景色

但发现上面的修改对 toolbar 没有起作用,而通过下面的代码可以拿到修改后的背景色

看来 mat-toolbar 不是通过 theme 的 background 获取背景色的。

查看的 define-light-theme 的实现源码 _theming.scss 发现下面的代码

由此猜测 toolbar 可能是 legacy theme

进一步查看 toolbar 的实现源码 _toolbar-theme.scss

的确是 legacy theme 。

最终在之前的代码基础上添加下面的代码解决了问题。

本文:基于angular material theming机制如何修改mat-toolbar的背景色的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:微信小程序中如何实现富文本编辑器下一篇:

19 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18