问题描述
抱歉我缺乏技术语言!
所以,我想要做的是一个将在 OBS(开放广播软件)中使用的 twitch 订阅计数器,我制作了实际计算 node.js 中订阅数的部分(我实际上有它们来保存数字文本文件中发生了多少订阅)。我缺少的是会在 OBS 上显示的部分,这是我用 html 和 CSS 制作的实际图形计数器。我这样做是为了当我运行 node.js 文件时,它使用带有 html 的 http.createServer().listen(port)
函数创建一个本地 Web 服务器 (localhost:etc)。
问题是我需要调用一个函数 (setValue()
),它位于 HTML 文件中的 Java 脚本脚本中,它会更改计数器状态(百分比和条形填充)......有没有办法做到这一点?
html 脚本代码:
<script type="text/javascript">
let reader = new FileReader();
class ProgressBar {
constructor(element,initialValue = 0) {
this.valueElem = element.querySelector('.progress-bar-value');
this.fillElem = element.querySelector('.progress-bar-fill');
this.setValue(initialValue);
}
setValue(newValue) {
if(newValue < 0){
newValue = 0;
}
if(newValue > 100){
newValue = 100;
}
this.value = newValue
this.update();
}
update() {
const percentage = this.value + '%';
this.fillElem.style.width = percentage;
this.valueElem.textContent = percentage;
}
}
var pb1 = new ProgressBar(document.querySelector('.progress-bar'),50);
</script>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)