日常问题

237 阅读2分钟

1、mac ssh 路径查询

打开finder 摁commod+shift+G  搜索文件,输入~/.ssh 是个文件夹

2、eslint 和 prettier 保存时冲突

// 保存时格式化 关闭第一个就好了
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
}

3、Cannot read property ‘range’ of null

  1. .eslintrc.js 添加以下规则
// .eslintrc.js
module.exports = {
    rules: {
        indent: 'off', 
        'template-curly-spacing': 'off'
    }
}
  1. 最简单粗暴的方法: 在对应的工程里直接删除里面的node_modules文件夹,然后重新npm install下,注意在npm install 之前最好先清理下缓存,防止node_modules 出现某一些包错误时候,查不到原因。npm 清理下缓存指令
$ rd node_modules
$ npm cache clean
$ npm install
$ npm cache clean // npm cache clean --force 
  1. 把下图中红色部分的中的^ 去掉,重新下载,问题解决。

image.png

4、Cannot read properties of undefined (reading 'parseComponent')

vue 和 vue-template-compiler 版本不一致造成的

5、jsx 绑定自定义指令

const directives = [
    {
        name: 'tap',
        value: this.onAdd,
    },
];
return (<Button
  class={cls}
  style={style}
  icon="plus"
  disabled={this.isAddDisabled}
  {...{ directives }}
/>

6、node 源设置

npm config set registry registry.npm.taobao.org

7、lf 和 crlf 问题

vscode 点击文件 --》首选项 --》 设置 --》 搜索 eol,改变eol为\n(指lf)或者改为(\r\n),有一个统一的标准就好了。

eslintrc.js 文件中加入

rules: {
    endOfLine: 'off',
}

8、node-sass 换源

npm config set sass_binary_site cdn.npm.taobao.org/dist/node-s… -g

9、whistle 抓包代理

详细地址:juejin.cn/post/707738…

安装 whistle:

npm install -g whistle

启动 whistle:

w2 start

打开 localhost:8899 就能看到界面了

然后配置手机代理

wify -> 代理服务器 -> 手动 -> ip: PC的本地IP & 端口:8899

安装证书

安装证书请参考文档: wproxy.org/whistle/web…

打开网站的 https 菜单 勾选两个复选框 iPhonne 手机自带扫码功能 下载证书 设置 -> 已下载的安装描述 或者 设置 -> 通用 -> Vpn与设备管理

证书信任

设置 -> 通用 -> 关于本机 -> 证书信任设置 - 打开 whistle

10 vscode 项目单独配置设置

在项目的根目录下,创建一个 .vscode 文件夹,该文件夹下新增 settings.json 文件

{
  // 保存自动格式化代码
  "editor.formatOnSave": true,
}

11 vite启动 访问502

使用 comman + space键 搜索代理(M1和Intel的系统貌似不同,有些设置不好找就直接搜索了)

输入: 代理

回车进入,找到最下面的下面忽略那一栏目中,添加自己设置的代理域名,避免过后出现502报错