This article mainly introduces the method of debugging dynamic js scripts in the browser. The article brings you two debugging methods, which are very good and have reference value. Friends in need can refer to the first two
Tianla modified the company's front-end code and found that in the sources option of the developer tools, the js script I wanted to debug was not listed. Later, I observed that the script was dynamically introduced in the page. This may be why it is not displayed. But if you can't debug breakpoints, just printing logs is really tiring, and the efficiency is too low. I tried searching on the Internet, and there are two ways to solve it:
1. Add it to the script. //# sourceURL=xxxxxxxxx.js, name it yourself, you can use the file name directly, as shown below:
Then open the page containing this js in the web page, so that You can see it in the developer tools. You can break points and debug normally like ordinary js
2. The second method is to use console.log("Let Let me debug it!") Print the log. After seeing the output in the browser console, click the link below to jump into the dynamic script. The name is generally vmXXX, as shown below:
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Detailed introduction to several JavaScript coding specifications (detailed tutorial)
Detailed introduction to the source code entry file in vue ( Detailed tutorial)
How vue springboot implements single sign-on cross-domain issues (Detailed tutorial)
How to implement scroller return to the page in vue and remember the scroll position
How to implement reading and writing cookies in JavaScript
How to implement multiple file downloads in WeChat applet
Explain the Object object in detail in JS
The above is the detailed content of What are the methods for debugging js scripts?. For more information, please follow other related articles on the PHP Chinese website!