如何在Hydrogen v1服务器组件中使用控制台日志记录

huangapple go评论56阅读模式
英文:

How to console log in Hydrogen v1 server components

问题

我是一个初学者,开始使用基于React的无界商务堆栈Hydrogen,然而,当我尝试在.server.tsx组件中使用console.log时,我没有得到任何输出。我该如何做?

英文:

I am a beginner starting using Hydrogen the react-based headless commerce stack, however when I try to console.log in .server.tsx components, I dont get any outputs.
How can I do that?

答案1

得分: 0

在组件内部进行控制台操作时,它将被视为客户端,并且您将能够在浏览器控制台中看到该控制台。

但是,在服务器组件内部进行控制台操作时,它将在服务器端运行,因此该控制台将在您启动本地开发应用程序的终端中可见。

英文:

While doing console inside component, it will treat it as client side and you will be able to see that console in browser console.

But while doing console inside server component, it will be running on server side, thus that console will be visible in terminal from where you have started your application for local development.

huangapple
  • 本文由 发表于 2023年7月11日 03:44:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76656861.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定