简体   繁体   English

如何更新 Material Design lite 徽章数量

[英]How to update material design lite badge count

How can I update the data-badge count on a Material Design Lite badge in javascript?如何在 javascript 中更新 Material Design Lite 徽章上的数据徽章计数? For example, the count of new notifications on a notification badge after fetching the notifications from the database.例如,从数据库中获取通知后通知徽章上的新通知计数。

Found the solution in Javascript:在 Javascript 中找到解决方案:

let element = document.getElementById("#yourBadgeId");

element.setAttribute("data-badge" , yourValue);

make sure that in the html script, the mdl badge tag should not contain the data-badge attribute确保在 html 脚本中,mdl 徽章标签不应包含 data-badge 属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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