- 博客(3)
- 收藏
- 关注
原创 # [解构如何运用的解构--报错 throw new TypeError(‘Router.use() requires a middleware function but got a ‘ + gett
let aa={ error_code: 0, reason: "插入数据成功" };//如何拿到 error_code 和 reason 的值let { error_code, reason } = aa; console.log(error_code,reason); // 输出0 和 插入数据成功 对于报错throw new Typ eError('Router.use() requires a middleware function but got a ’ + gettype(fn))
2020-09-24 18:08:47 213
原创 Commonjs模块的导入导出,module.exports 和 exports 的区别以及包管理器
Commonjs 里面模块的导入导出 在 Commonjs里面,通过module.exports来导出一个模块,通过require来导入一个模块。 示例如下: // index2.js module.exports.name = "xiejie"; module.exports.sayHello = function(){ console.log('Hello'); } const obj = require('./index2.js'); console.log(obj.name); // xi
2020-09-20 10:15:28 524
原创 使用 http 模块来实现简单的爬虫及资源压缩
所谓爬虫,就是用来爬取网页的内容。 在 nodejs 中,可以使用 http 和 https 模块来实现简单爬虫。会使用到一个模块,cheerio 模块。该模块可以将返回的字符串转为 jQuery 中的 $ 对象,从而可以使用 jQuery 中的各种方法。 const https = require('https'); const cheerio = require('cheerio'); // 爬虫的思路很简单,其实就是发送 http 请求,去请求那个页面 // 接下来拿到响应的内容,然后筛选有用的信.
2020-09-20 10:09:40 248
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人