xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

How to use VS Code to debug Next.js applications All In One

How to use VS Code to debug Next.js applications All In One

difficulty: Medium / 难度: 中等

debug your Next.js frontend and backend code

.vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Next.js: debug server-side",
      "type": "node-terminal",
      "request": "launch",
      "command": "npm run dev"
    },
    {
      "name": "Next.js: debug client-side",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:3000"
    },
    {
      "name": "Next.js: debug full stack",
      "type": "node-terminal",
      "request": "launch",
      "command": "npm run dev",
      "serverReadyAction": {
        "pattern": "- Local:.+(https?://.+)",
        "uriFormat": "%s",
        "action": "debugWithChrome"
      }
    }
  ]
}

image

https://nextjs.org/docs/pages/building-your-application/configuring/debugging

  1. Visual Studio Code

image

https://code.visualstudio.com/docs/editor/debugging

  1. Chrome DevTools

image

https://developer.chrome.com/docs/devtools?hl=zh-cn

demos

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

js guard clause

const nToS = (number) => {
  // guard clause 保护条款 / 守卫条款
  if(!Number.isInteger(number)) return;
  return `${number >= 0 ? number : `(${Math.abs(number)})`}`;
}

console.log(nToS())
console.log(nToS(undefined))
console.log(nToS(null))
console.log(nToS(7))
console.log(nToS(-7))

// undefined
// undefined
// undefined
// 7
// (7)

https://youtu.be/g2nMKzhkvxw?si=lyuL44Y2GKwwZwqC&t=474

const nToS = (number) => {
  // guard clause 保护条款 / 守卫条款
  if(number === null) return;
  return `${number >= 0 ? number : `(${Math.abs(number)})`}`;
}

/* 

undefined == null
true
undefined === null
false

*/

/* 

isNaN(undefined)
true
isNaN(null)
false
isNaN(false)
false
isNaN(-5)
false
isNaN({})
true
isNaN([])
false

*/


/* 

Number.isInteger(-5)
true
Number.isInteger(5)
true
Number.isInteger(null)
false
Number.isInteger(undefined)
false

*/

refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2024-07-25 01:09  xgqfrms  阅读(15)  评论(1编辑  收藏  举报