在 chrome 中加载本地 javascript 文件进行测试? [英] Load local javascript file in chrome for testing?

查看:35
本文介绍了在 chrome 中加载本地 javascript 文件进行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Chrome 浏览器在本地计算机上测试一些 JavaScript,但 Chrome 不会加载本地资源.有没有简单的解决方法?

I am trying to test some JavaScript on my local computer using the Chrome browser but Chrome will not load local resources. Is there an easy work around for this?

推荐答案

如果你只是想测试你的 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>

这篇关于在 chrome 中加载本地 javascript 文件进行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆