- 云开发http上传文件代码
const request = require('request-promise') const config = require('./config'); const fs = require('fs') module.exports = async (ctx) => { const files = ctx.request.files //koa2后台接收到文件组,需要npm koa-body且multipart : true let file = files[0] try { let options = { uri: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' + config.appId +'&secret=' + config.appSecret + '', json:true } let {access_token} = await request(options) //得到access_token let fileName = `example.jpg` let filePath = `dir/${fileName}` options = { method: 'POST', uri: 'https://api.weixin.qq.com/tcb/uploadfile?access_token=' + access_token + '', body: { "env": 'cloud-a8eeXX', "path": filePath, }, json: true } let res = await request(options) //获得文件上传许可以及各种参数 options = { method: 'POST', uri: res.url, formData: { "Signature": res.authorization, "key": filePath, "x-cos-security-token": res.token, "x-cos-meta-fileid": res.cos_file_id, "file": { value: fs.createReadStream(file.path), options: { filename: fileName, contentType: file.type } } } } ctx.body = await request(options) //上传文件,cox.body返回结果给前端 } catch (err) { console.log(err.stack) } } [图片]
2020-10-20 - textarea 的层级为什么比所有的元素层级都高
页面用了textarea, 然后有个弹窗(action-sheet),点击弹窗之后,textarea 还是可以获取光标,还是在最上一层,而且textarea 还是可以上下滑动,明显textarea 层级最高,请问如何解决?
2019-07-09