Today, when programming, the JavaScript program reported the error: cannot use ' in ' operator to search for ..., the specific error message is as follows: Frankly, such errors are the hardest to debug. Because it does not point to the specific code you write, but to the general point of the Lib.js file (which is usually a third-party packaged compression library), you can hardly locate the wrong location in actual programming based on the type of error and the error point.
What to do? This time, only play "Dead knock" spirit! Dead Knock Steps:
- It should be easy to locate the wrong file based on the fault page and the error message;
- In the error page, click Debug, then look at which step began to error! It's critical! For example, at the beginning of the load error, then locate the initialization of the JS file, click on a button error, then locate the button's corresponding event code, and so on.
- In the code range of the positioning, using the "compromise method", a little comment out, refresh the page to see if there is still error, if the error, this means that commented out part of the code is not a problem, let go of the comments, continue other suspicious code part; If there is no error, congratulations, your location is more refined! The general idea is so, the cycle, I believe, there will always be "to clear the clouds to see the blue sky" of joy!
1 console.log (' rendernerererer: ', Schooldata)23 Const Schoolnode = ( 4 <select style={{width: ' 100% '}} placeholder= "Please select your school" >5 {schooldata.length && Schooldata.map (item, IDX) = (6 <option key={idx} value={' ${item.id} '}>{ Item.name}</option>7) }8 </Select>9 );
As you can see, Rendernerererer is printed correctly, and the problem follows the line code:
1 Const SCHOOLDATA = this .state.schoollist; 2 console.log (' rendernerererer: ' 6 {schooldata.length? schooldata.map (item, IDX) => ( 7 <option Key={idx} value={' ${item.id} '}>{i Tem.name}</option> 8 ): <option value= ' > Please select ...</option>} 9 </select>10 );
1Const SCHOOLDATA = This. state.schoollist;2Console.log (' Rendernerererer: ', Schooldata)3 4Const SCHOOLNODE = (5<select style={{width: ' 100% '}} placeholder= "Please select your school" >6{schooldata.length? schooldata.map (item, idx) = = (7<option key={idx} value={' ${item.id} '}>{item.name}</option>8)) :NULL }9</Select>Ten);
JavaScript program error: Cannot use ' on ' operator to search