There is a problem after the local code is packaged and compiled normally - the class name obtained by Class.name cannot be used as a variable for judgment!

Table of contents

1. Problems

Two, the reason

 3. Summary


1. Problems

1. Write a piece of code: use the class name .name to distinguish different classes , how to see it locally, how to test it is correct! I don’t understand why it’s a problem after packaging: it doesn’t enter the processing logic in if.


export const mapClassName = mapClass.name;
if(mapClassName==='Locpard"){
 //处理逻辑
}

Two, the reason

1. Print the mapClassName in front of the if, and saw a magical thing. . . . After packaging, the class name obtained by Class.name is not the Locpar I named it. . . . (The previous error code has been updated, and I forgot to take a screenshot, so I took a screenshot)

 3. Summary

1. For some things that you are not sure about, try not to use them as variables for judgment.

2. Generally, only constants can be used  as variables for logical judgment .

3. Do not use the class name as a variable for judgment (pit @-@)

/*
Hope it helps you!

If there is any mistake, welcome to correct me, thank you very much!

*/ 

Guess you like

Origin blog.csdn.net/qq_45327886/article/details/132214110