捆绑后,在浏览器中测试JavaScript/Typescript的一种方法
我正在和我的朋友一起写网络应用。他写了前面的书,我写了后端。问题是,如果我的朋友还没有编写集成,我无法测试代码,因为我们将代码捆绑在Web Pack中并在Dev Server上运行。我的问题是,是否有一种方法可以在Chrome控制台中测试我的打字稿代码(带有参数的调用功能),就像我可以测试未捆绑的JavaScript一样?
I'm writing a web app with my friend. He writes the Fronted, I write the Backend. Problem is that there is no way of me testing my code if my friend haven't wrote the integration yet, because we bundle the code in web pack and run it on a dev server. My question is, is there a way that I could test my typescript code (call functions with parameters) in chrome console, like I could test unbundled javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
专业答案是:不要那样做!
这很难强大的大“如果”!
因此,现实答案可能是:写...或让您的朋友写...一个丑陋但功能的页面,您可以使用一些值来输入一些值,然后单击按钮提交它,然后然后添加
调试器
作为按钮代码开始附近的语句。debugger
是一个硬码断点,开发工具将暂停。一旦编写和工作,您应该能够根据需要对其进行修改。 ...只记得不要让该页面逃脱到生产中。
The professional answer is: Don't do that!
And that's hard but you'll be glad you did it... if you can do it without the project dying because of it! For a project that is just you and a friend, that may be a mighty big "if"!
So the realistic answer is probably: Write... or get your friend to write... an ugly-but-functional page you can use to enter some values and click a button to submit it, and then add
debugger
as a statement near the start of the button code.debugger
is a hardcode breakpoint that dev tools will pause at.Once that's written and working you should be able to modify it as needed. ...just remember not to let that page escape into production.