简体   繁体   中英

javascript settimeout function in aurelia

I want to hide an element after some time ( about 2 seconds ). in javascript in can use setTimeout function for that. Is there a way that I could use it on Aurelia? or is there a better way for this?

You can hide the element using the if custom attribute included in Aurelia. Then bind that to a property on the viewmodel.

this.showItem = true;
window.setTimeout(() => this.showItem = false, 2000);
<h1 if.bind="showItem">I will hide in 2 seconds</h1>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM