变量分配不可能,调试器 - 变量<not available =“”>最需要的帮助

时间:2015-08-13 19:57:57

标签: javascript jquery

情况如下:

function vartest(a, b, c){
  var angle =b;
  var speed = a;
  var  g=c;
  var time=0.5, v0, angle1;
  v0 = speed;
  alert("Type of angle 1"+typeof(angle1));
  window.alert("angle "+angle);
  angle1 = (angle*3.14)/180; 
  alert("Type of angle 1 second try: "+typeof(angle1));
  window.alert("angle1 "+ angle1 ); 
 }
 //sliders from which i take angle, speed and gravity acceleration
 $(function(){
  $(".slider").slider()
  $("#angle").slider({
    value:30,
    min:0,
    max:250,
    step:0.2,
    slide: function (event, ui){
       $( "#angres" ).html( ui.value );
       angle = ui.value;
      // trajgen();
      }
    });
  $("#speed").slider({
    value:0,
    min:0,
    max:250,
    step:0.2,
    slide: function (event, ui){
      $("#spdres").html(ui.value);
      speed = ui.value;
     // trajgen();
     }
   });
  $("#gravity").slider({
    value:9.8,
    min:0,
    max:250,
    step:0.2,
    slide: function(event, ui){
      $("#gravres").html(ui.value);
      g = ui.value;
     // trajgen();
     }
   });   
  });

 //a fair attempt to assign the variable below with the initial values of 
 // the sliders, debugger shows that this doesn't work, it's OK but does not
 // assign anything
 $("#angres").html($('#angle').slider('value'));
 var angle = $( "#angle" ).slider( "option", "value" );
 $("#spdres").html( $("#speed").slider('value'));
 var speed = $( "#speed" ).slider( "option", "value" );
 $("#gravres").html($("#gravity").slider('value'));
 var g = $( "#gravity" ).slider( "option", "value" );

if(speed!=undefined&&angle!=undefined&&g!=undefined){
  vartest(angle, speed, g);
}

问题是 - 调整滑块后,他们成功地将anglespeedgravity传递给vartest,但后来成为angle1 = (angle*3.14)/180它允许angle1 =&#39;不可用&#39;。如何解决这个问题。我第4天就是在解决这个问题,由于我在这里的一个人的努力和帮助,我能够将angle1NaN更改为“不可用”#39;我应该承认,即使现在初始化angle1NaN,但与之前的尝试不同,此angle1NaN更改为“不可用”#39;这是一个公平的进步。但是,angle1的类型无论在angle1= (angle*3.14)/180;行之前还是之后都是数字。如果没有滑块功能,我设置了一个值,让我们说angle =150然后angle1就可以了。

0 个答案:

没有答案