首页 > 解决方案 > scss自定义mixin覆盖更改值不替换,但添加它

问题描述

我想覆盖边界半径值04px

不替换,但添加它。我究竟做错了什么?

@import:主题.scss:

.uk-button {
    border-radius: 0;
    @if(mixin-exists(hook-button)) { @include hook-button(); }
}

自定义.scss:

// Custom mixin overwrites
// that's correct?
@mixin hook-button() {
    border-radius: 4px;
}

意外结果:

.uk-button {
    border-radius: 0; 
    border-radius: 4px;
}

预期结果:

.uk-button {
    border-radius: 4px;
}

标签: csssassscss-mixins

解决方案


@include,正如它所说,仅添加/包含特定规则,但不会替换它们。

主题 SCSS 应如下所示:

.uk-button {
    @if(mixin-exists(hook-button)) { @include hook-button(); }
    @else { border-radius: 0; }
}

推荐阅读