How to change the background color of button in Footer area
我們遇到的問題是改button text的顏色,比如把你們例子中的“follow me”字體改成藍色。
你們email中的核心思想是找到button然后通過addStyleClass() 來修改button的css
如果我的理解沒有錯誤的話,我已經嘗試過了,但是其實修改button的css style并不能改變button text的style。
我有一個button,id是”interactionButton”它的text是“0 Requests”,我要根據不同的情況還改變 button text的顏色。
看我截圖黃色highlight部分,目前我們發現只有改” interactionButton-inner”或者“interactionButton-content”的css style才能改text 的顏色,改動button “interactionButton”是不work的曾經嘗試在controller.js 的onAfterRendering方法里面通過拿到this.getView().byId(“interactionButton-inner”)或者this.getView().byId(“interactionButton-content”)來change style,
但其實在onAfterRendering方法里面,interactionButton-inner和interactionButton-content 都還沒有被render,所以嘗試失敗
目前我們一個非常ugly的solution如下,直接修改div。。我覺得這樣不是個good solution。。。。
solution
首先看為什么byId, 傳button id進去能夠訪問到button:
因此這里有兩個維度的東西:
但是這個native html tag并不會注冊到core的this.mElements去,因此byId() query不出來。
所以再回到你的需求,button的inner div這個實現對于我們application developer是透明的。如果我們要修改text color, 只能通過button 提供的API。
但是API 文檔上button只有setText的功能,那我們先看看setText 是怎么被框架實現的?
通過讀代碼發現和你的實現一致。
因此我們可以得出一個generic的結論:
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的How to change the background color of button in Footer area的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是COS操作系统
- 下一篇: 怒晴湘西陈瞎子怎么瞎的(汉典怒字的基本解