Home >Web Front-end >JS Tutorial >What are the methods for debugging js scripts?

What are the methods for debugging js scripts?

亚连
亚连Original
2018-06-11 14:38:241595browse

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)

Detailed introduction to the encapsulation of commonly used tool classes in javascript (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 view deep copy in vue

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn