[英]How to change the input field color in Ionic 5 when focused?
我想在聚焦時更改輸入字段的顏色。 它只是灰色,當它被以下函數聚焦時,只要我不輸入或點擊該字段。
export function autofocus() {
let blanks = document.querySelectorAll(".blank")
let textfield = document.getElementById("textfield")
if (blanks.length > 0) {
document.querySelectorAll(".blank")[0].setFocus()
}
else if (textfield) {
document.getElementById("textfield").setFocus()
}
}
負責它的類是:
:host(.ion-focused) .item-native::after {
background: var(--background-focused);
opacity: var(--background-focused-opacity);
}
不幸的是,它是 Shadow DOM 的一部分。 有誰知道,如何解決? 不透明度應該為零。
解決了。
ion-item.ion-focused::part(native)::after {
opacity: 0!important;
}
對我有幫助的資源:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.