enoyao

Results 183 comments of enoyao

# Vue + Typescript - [Vue TypeScript 支持](https://cn.vuejs.org/v2/guide/typescript.html) # data ```ts import { Component, Prop, Vue } from 'vue-property-decorator'; @Component export default class HelloWorld extends Vue { @Prop() private msg!:...

# React + Typescript 使用 TSX 我们可以这样写,后缀记得为`.tsx`,与js的区别是,使用ts开发过程中需要先定义一个接口,规范数据类型,通过泛型传入到类中 ```ts import * as React from 'react' interface IProps { color: string, size?: string, } interface IState { count: number, } class App...

# 微信小程序 由于 `setData` 和 `data` 都被声明为可选项,使用时需要加上 `!` ,`this.setData!({})` 和 `this.data!` ```js interface InterObj { age?: number } Page({ data: { skill: ['ps', 'js', 'css'] as string[], name: 'yao' as...

注意要遍历生成多个写入流,不然有可能下载文件写入不成功 ```js for(let i = 0; i < imgs.length; i++) { var imgStream = fs.createWriteStream(`./img/vks${i}.jpg`); download(imgs, i, imgStream) } ``` 完整代码,记得创建img文件夹 ```js var http = require("http"); var fs = require("fs");...

在pipe之前添加on('error',fn)可以监听错误,在后面添加on('close',fn)可以监听完成 ```js var s = fs.createWriteStream(`./images/${f}/${i}`) request(url).on('error', (err) => { console.log(err) }).pipe(s).on('close', () => { console.log('成功!') }) ``` # 参考文档 - [Downloading images with node.js ](https://stackoverflow.com/questions/12740659/downloading-images-with-node-js) - [关于抓取图片时候遇到的错误 Unhandled stream...

# 安装并引用request模块 [官方详细文档](https://www.npmjs.com/package/request) ```js const request = require('request'); ``` # 详细配置的写法 ```js request({ method: 'GET', url: 'https://xxx/config/all', headers: { 'Host': 'api.veilpark.com', 'mid': '8678385b7d1eb259377973ee02cd9d52618fc0f7', 'Accept': '*/*', 'Authorization': 'token 40101431f0c64e83839a56c2069b1a63jcrk8on1', 'Proxy-Connection': 'keep-alive',...

# 酷狗批量下载音乐 参考1 ```js var request = require('request'); var cheerio = require('cheerio'); var fs = require('fs'); request('http://www.kugou.com/yy/singer/home/3060.html', function(error, response, body) { //console.log(body) var $ = cheerio.load(body); var arr = $('.song_hid');...

# 原生http.request模拟客户端请求 ```js const http = require('http'); const querystring = require('querystring'); const postData = querystring.stringify({ 'msg': 'helloworld' }); const options = { hostname: 'localhost', port: 8877, path: '/', method: 'POST',...

# 英文教程 - [Tutorialspoint](https://www.tutorialspoint.com/nodejs/nodejs_first_application.htm) - [Introduction to Node.js](https://www.guru99.com/node-js-tutorial.html)

# AWS [亚马逊云服务器官网](https://aws.amazon.com) 可以把在本地`ssh-keygen`命令生成的`Github`的`ssh`私钥上传上去,然后在创建服务器时候使用密钥对来生成钥匙,然后使用`microsoft remote desktop for mac`进行连接,可以导入`rtp`文件,配合本地的公钥来进行解析密码登录