0
我有以下离子html代码。无法更改离子离子视图栏的背景颜色?
<ion-nav-bar class="backarrow-bar" style="background-color:rgba(99,99,99,.5)">
<ion-nav-back-button class="button-clear">
<i class="ion-chevron-left" style="color:#ffffff;text-shadow: 2px 4px 3px rgba(0,0,0,0.3);"></i>
</ion-nav-back-button>
</ion-nav-bar>
而下面的代码被用来改变ion-nav-bar
的背景色。但是,背景颜色无法更改。我甚至把背景颜色的内联样式用于测试,但它仍然不起作用?
.directive('headerShrink', function ($document) {
return {
restrict: 'A',
link: function ($scope, $element, $attr) {
var header = $document[0].body.querySelector('.backarrow-bar');
var headerHeight = 44;
$element.bind('scroll', function (e) {
var scrollTop = e.target.scrollTop;
var alpha = Math.min(scrollTop/44, 1);
// Not working
header.style.backgroundColor = 'rgba(99,99,99,' + alpha + ')';
// Not working either
// ionic.requestAnimationFrame(function() {
// header.style.backgroundColor = 'rgba(0,0,0,' + alpha + ')';
// });
});
}
}
})
在SO回答中,它也使用'this.style.backgroundColor =“rgba(”+ [match [1],match [2],match [3 ],a] .join(',')+“)”;'像我一样分配backgroundColor? – ca9163d9
你确定你的案例中的alpha值是一个浮点数<1吗?你有没有通过建议的更改进行检查 –
是的,在铬调试显示其小于或等于1。 – ca9163d9