gpt4 book ai didi

Javascript 使用 IF/ELSE 写入变量并将其插入到另一个变量中

转载 作者:行者123 更新时间:2023-12-03 11:36:33 24 4
gpt4 key购买 nike

我有以下问题:

var widowwidth = 0,w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')      [0],x=w.innerWidth||e.clientWidth||g.clientWidth;

if( x > 1624) {
widowwidth = 1800 / (10 + 2);
}
else {
widowwidth = 800 / (10 + 2);
}

现在我想给meterNum var: windowwidth

_drawSpectrum: function(analyser) {
var that = this,
canvas = document.getElementById('canvas'),
cwidth = canvas.width,
cheight = canvas.height - 2,
meterWidth = 10,
gap = 10,
capHeight = 2,
capStyle = '#fff',
meterNum = windowwidth, // <----- HERE

有一个简单的方法还是我犯了一些错误,因为它不起作用:(

谢谢你,Tim4497

最佳答案

在变量初始化和 if else 语句中,您定义变量 widowwidth 而不是 windowwidth。如果变量的另一半还没有死,您需要更正它以使其工作。

关于Javascript 使用 IF/ELSE 写入变量并将其插入到另一个变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26471834/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com