错误未捕获的ReferenceError:赋值中的左侧无效

时间:2018-05-11 13:43:51

标签: javascript

我有详细的功能,它给了我以下错误

  

未捕获的参考错误:分配中的左侧无效。

function obtenerValorPorColorSemaforo(sumCumplimiento, valueColorVerde, valueColorAmarillo) {
         var result = null;
         var porColorVerde = parseFloat(valueColorVerde); // Porcentaje Color Verde
         var porColorAmarillo = parseFloat(valueColorAmarillo); // Porcentaje Color Amarillo.

         if (parseFloat(sumCumplimiento) = 0.00) {
           // Color gris
           result = "panel-defaluft";
         }

         else if (parseFloat(sumCumplimiento) >= porColorVerde) {
           // Color VERDE
           result = "panel-success";
         }

        else if(parseFloat(sumCumplimiento) < porColorVerde &&
                parseFloat(sumCumplimiento) >= porColorAmarillo) {
           // Color AMARILLO
           result = "panel-warning";
         }

         else  {
           // Color ROJO
           result = "panel-danger";
         }

         return result;

       }

2 个答案:

答案 0 :(得分:0)

这是你的问题:

    if (parseFloat(sumCumplimiento) == 0.00) {
       // Color gris
       result = "panel-defaluft";
     }

它应该是:

TAL EXCEPTION: main
Process: com.finchvpn.androidcloudpark, PID: 1579
    java.lang.IllegalStateException: Could not execute method for android:onClick
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:389)
    at android.view.View.performClick(View.java:4438)
    at android.view.View$PerformClick.run(View.java:18422)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384)
    at android.view.View.performClick(View.java:4438) 
    at android.view.View$PerformClick.run(View.java:18422) 
    at android.os.Handler.handleCallback(Handler.java:733) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5001) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
    at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.NullPointerException
    at com.finchvpn.androidcloudpark.MainActivity.loginButtonClick(MainActivity.java:74)

答案 1 :(得分:0)

你在if

中正在做什么
 if (parseFloat(sumCumplimiento) = 0.00) {
   // Color gris
   result = "panel-defaluft";
 }

可能你错过了额外的==