zhangzheng-zz / blog

1 stars 0 forks source link

H5移动端及浏览器调试方法 #6

Open zhangzheng-zz opened 3 years ago

zhangzheng-zz commented 3 years ago

chrome 远程真机调试 H5 页面

有时候,我们需要调试嵌入到安卓appH5项目,一般这样的H5项目只有一个线上的链接,在浏览器上无法模拟出安卓的环境,加上移动app端也没有浏览器的开发者工具,这就给H5页面调试造成了不便,这里介绍一种利用chrome浏览器进行远程真机调试的方法:_

vscode 断点调试 node 项目

launch.json配置:

{
            "type": "node",
            "request": "launch",
            "name": "node 调试",
            "skipFiles": [
                "<node_internals>/**"
            ],
            // node 项目入口文件路径
            "program": "${workspaceFolder}\\test.js"
 }

vscode 调试 Vue 项目

以 vue-cli 脚手架为例,开发环境开启源码映射

// vue.config.js
module.exports = {
  configureWebpack: {
    devtool: 'source-map'
  }
}
{
            "type": "chrome",
            "request": "launch",
            "name": "vuejs 调试",
            // 项目启动地址
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}/src",
            "breakOnLoad": true,
            "sourceMapPathOverrides": {
                "webpack:///src/*": "${webRoot}/*",
                "webpack:///./src/*": "${webRoot}/*"
            }
 }