有没有一种方法可以在Chrome中创建和运行JavaScript? [英] Is there a way to create and run javascript in Chrome?

查看:57
本文介绍了有没有一种方法可以在Chrome中创建和运行JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome中是否可以使用扩展程序或应用程序之类的方法在Chrome中创建和运行.js文件?

解决方案

如果您不想显式创建js文件,但仍想测试您的javascript代码,则可以使用代码片段来运行JS代码. /p>

请按照以下步骤操作:

  1. 打开开发工具
  2. 转到来源"标签
  3. 在来源"标签下,转到代码段+新代码段
  4. 在编辑器中粘贴您的JS代码,然后在Mac中运行Command + Enter.如果您使用console.log或类似的东西来测试,则应该在console中看到输出.您可以编辑当前具有打开或运行脚本的网页,加载更多的javascript文件. (请注意:除非您明确指定,否则这些代码段不会以js文件的形式存储在计算机上,因此,如果删除chrome,您将丢失所有代码段);
  5. 如果您右键单击摘要,也可以选择另存为摘要.

Is there a way, like an extension or application, in Chrome to create and run .js files in Chrome?

解决方案

if you don't want to create an explicitly a js file but still want to test your javascript code, you can use snippets to run your JS code.

Follow the steps here:

  1. Open Dev Tools
  2. Go to Sources Tab
  3. Under Sources tab go to snippets, + New snippet
  4. Past your JS code in the editor then run command + enter in Mac. You should see the output in console if you are using console.log or similar to test. You can edit the current web page that you have open or run scripts, load more javascript files. (Just note: this snippets are not stored on as a js file, unless you explicitly did, on your computer so if you remove chrome you will lose all your snippets);
  5. You also have a option to save as your snippet if you right click on your snippet.

这篇关于有没有一种方法可以在Chrome中创建和运行JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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