且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 chrome 中加载本地 javascript 文件进行测试?

更新时间:2023-12-05 20:18:10

如果你只是想测试你的 JavaScript 文件的功能:创建一个空白的 HTML 文件,添加一个指向你的 JS 文件的链接,就像你通常加载一个JS 文件,然后在 Chrome 中打开 HTML 文件.转到 JavaScript 控制台.您将能够像往常一样与 JS 代码的功能进行交互.您不需要为此设置服务器.如果还不清楚,这里是一个例子:

If you are trying to just test the functionality of your JavaScript file: create a blank HTML file, add a link to your JS file as you would normally load a JS file from HTML, and open the HTML file in Chrome. Go to the JavaScript console. You'll be able to interact with the functionality of your JS code as usual. You wouldn't need to set up a server for this. If still not clear, here's an example:

<html> 
    <head> 
        <script type = "text/javascript" src = "path/to/your/jsfile"></script>
    </head> 
</html>