- 博客(18)
- 收藏
- 关注
原创 node.js 返回的响应出现中文乱码问题
解决办法:在响应头中指定编码方式res.writeHead(200,{'Content-Type':'text/plain;charset=utf-8'})
2021-05-18 17:20:59
523
原创 nodejs连接MySQL数据库时报错:‘Client does not support authentication protocol requested by server‘
当我执行命令node xxx.js时,报错信息如下:code: 'ER_NOT_SUPPORTED_AUTH_MODE',errno: 1251,sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client',sqlState: '08004',fatal: true解决办法:1、首先登录MySQL服务器:$ mysql -
2021-04-15 14:58:29
512
原创 npm安装时提示错误checkPermissions Missing write access to /Users/xxx/node_modules/scheduler
权限问题当我们使用npm install安装的时候,出现错误提示"checkPermissions Missing write access to /Users/xxx/node_modules/scheduler",这是由于权限的问题,导致了安装失败。解决办法办法1:尝试使用sudo npm install,但有些情况下无效。办法2:首先删除原先的node_modules文件夹执行npm install把node_modules文件夹的权限修改为777$ sudo chown -R 7
2021-03-01 12:44:03
896
原创 子元素设置margin-top会影响父元素
问题描述:当我只给子元素设置了margin-top当时候,父元素却也跟着一起改变了。代码部分:<style> .outer{ width: 200px; height: 200px; background-color: #eee; } .inner{ width: 50px; height: 50px; background-color: green; margin-top: 20px; } </style> <div class="
2020-07-29 13:55:08
305
原创 mac更改npm默认全局包安装路径
遇到的问题:通过npm更新yarn时,提示安装成功,但是通过yarn --version命令查询yarn版本的时候,结果还是旧版本号。想到之前因为权限问题修改过npm的安装路径,所以导致这个问题的出现。解决办法:1、修改npm全局安装目录npm config set prefix '目标目录'2、查看安装路径是否修改成功npm root -gps:Mac 下默认的全局路径是:/usr/local/lib/node_modules...
2020-07-13 20:51:48
5416
原创 create-react-app报错
执行"npx create-react-app my-app"时,报错:“A template was not provided. This is likely because you’re using an outdated version of create-react-app.”翻译:未提供模板。这可能是因为您使用的是过时版本的create-react-app。解决办法1、首先卸载掉旧版本,并且要确保卸载成功了npm uninstall -g create-react-apprm -rf /
2020-07-10 22:36:11
385
原创 升级node版本
1、清除缓存sudo npm cache clean --force2、安装n模块npm install -g n3、升级noden latest //升级到最新版本n stable //升级到稳定版本n xx.xx.xx //升级到指定版本
2020-07-10 21:39:23
371
原创 报错:“The engine “yarn“ is incompatible with this module. “
在终端执行命令时出现了标题所示的错误,解决方法如下:输入命令:yarn config set ignore-engines true
2020-07-10 21:32:20
1754
原创 CSS实现单行文本和多行文本溢出时显示省略号...
单行文本溢出实现单行文本溢出,通过使用以下属性:white-space:nowrap; //不换行overflow:hidden; //溢出的部分隐藏text-overflow:ellipsis; //溢出的部分显示为...具体代码:<style>p{ width:300px; line-height:50px; border:1px solid red; /*单行文本溢出*/ white-space:nowrap; overflow:hidden;
2020-06-29 21:50:17
207
原创 js字符串的常用方法
indexOf(str) 返回字符串中参数第一次出现的位置,若未找到则返回-1lastIndexOf(str) 返回字符串中参数最后一次出现的位置,若未找到则返回-1charAt(index) 返回指定位置的字符charCodeAt(index) 返回指定索引位置的字符的Unicode码substring(start[,end]) 查找指定位置的字符串,从start开始,到end结束但不...
2020-02-02 21:24:16
187
原创 js数组的常用方法
一、添加/删除:push() 向数组的末尾添加一个或多个元素,并返回新数组的长度pop() 删除数组的最后一个元素,并返回被删除的元素shift() 删除数组的第一个元素,并返回被删除的元素unshift() 向数组的开头添加一个或多个元素,并返回新数组的长度concat() 连接两个或多个数组,不会改变原数组小结:添加元素的方法返回值都是新数组的长度;删除元素的方法返回值都是被删...
2020-02-01 22:15:16
174
原创 关于document.body.clientHeight的返回值为0的问题
有时候我们需要去获取body的高度,但是通过document.body.clientHeight却得到值是0。那么如何解决这个问题呢?我们只需要将html和body的css样式中添加属性height:100%;即可。<!DOCTYPE html><html> <head> <meta charset="utf-8"> <titl...
2019-01-14 12:20:45
3736
2
原创 null和undefined的区别
一般我在平时使用null和undefined的时候明白它们是什么意思,但是当面试时被问到两者的区别,又会说不太清楚。之后查找了一些答案,总结下来就是:1.null代表一个空对象指针,通过typeof运算得到的是“object”,所以我们可以认为null是一个特殊的对象。那么在什么情况下使用null呢?通常我们定义一个变量,并且将来这个变量的值会是一个对象类型的值,那么我们就可以先将变量的值定义...
2019-01-02 22:55:16
468
原创 图片底部会有一点空白,如何去掉它
由于基线对齐的问题,图片底部会有一点儿空白 给img设置vertical-align:bottom可以解决此问题CSS:<style> div{ margin:0; padding:0; background-color: #ccc; font-size: 14px; line-height: 1.5em
2017-12-05 14:36:17
1081
原创 让元素水平垂直居中的方法
1.绝对定位法HTML:<body> <div class="box"></div></body>CSS:<style>.box{ position:absolute; top:0; bottom: 0; left:0; right: 0; margin: auto; width:100px; height:100px;
2017-12-05 14:25:20
276
原创 删除github远程仓库中的文件或文件夹
1.克隆远程仓库到本地库$ git clone 仓库地址2.对需要删除的文件、文件夹进行如下操作$ git rm xxx.txt (删除文件)$ git rm -r xxx (删除文件夹)3.提交修改$ git commit -m "Delete xxx"4.push到远程仓库$ git push origin master
2017-09-22 23:10:11
434
原创 查看或修改Git的用户名和邮箱
查看$ git config user.name$ git config user.email修改$ git config --global user.name "username"$ git config --global user.email "email"
2017-09-21 12:13:17
348
原创 Mac下搭建Vue开发环境
steps:1.安装HomeBrew$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"2.安装node$ brew install node3.使用淘宝镜像安装npm$ npm install -g cnpm --registry=https://re
2017-09-21 12:06:57
543
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人