简体   繁体   English

使用Chrome开发者工具实时修改脚本?

[英]Modify a script in realtime using Chrome Developer tool?

I try to modify <canvas> in realtime so I can learn fast, but because the code is used in the <script> so when I try to modify the code it dident get updated as i did with HTML or with the CSS. 我尝试实时修改<canvas> ,所以我可以快速学习,但因为代码在<script>所以当我尝试修改代码时,它会像HTML或CSS那样更新。

How to make it update in real time? 如何让它实时更新?

Code doesn't work like CSS or HTML (which is markup, not code, and it has a constant effect on the page). 代码不像CSS或HTML(这是标记,而不是代码,它对页面有一个恒定的影响)。 Your code is executed on page load, and if you change the code in the dev tools after it's run it's not going to un-execute your code so it can run the changed version. 您的代码在页面加载时执行,如果在运行后更改开发工具中的代码,它将不会取消执行您的代码,因此它可以运行更改的版本。

At least not from the dev tools. 至少不是来自开发工具。 Instead I recommend something like LiveReload which can watch for when you save files and then make your browser refresh itself. 相反,我建议像LiveReload这样的东西可以在你保存文件时观察,然后让你的浏览器自己刷新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM