当前位置: 首页 > news >正文

axios使用

参考地址:https://github.com/axios/axios

html

CDN

<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script>或者 <script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script>

使用


<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script><script>
axios.get('/json/transform', {params: {ID: 12345}}).then(function (response) {console.log(response);$("#key_json").val(response.data);}).catch(function (error) {console.log(error);});axios.post('/json/transform/post', {firstName: 'Fred',lastName: 'Flintstone'
}).then(function (response) {console.log(response.data);}).catch(function (error) {console.log(error);});</script>

并发请求示例

function getUserAccount() {return axios.get('/user/12345');
}function getUserPermissions() {return axios.get('/user/12345/permissions');
}Promise.all([getUserAccount(), getUserPermissions()]).then(function (results) {const acct = results[0];const perm = results[1];});

通过配置请求

axios(config)


// Send a POST request
axios({method: 'post',url: '/user/12345',data: {firstName: 'Fred',lastName: 'Flintstone'}
});
// GET request for remote image in node.js
axios({method: 'get',url: 'https://bit.ly/2mTM3nY',responseType: 'stream'
})
.then(function (response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});

为所有常见的请求方法提供了别名

axios.request(config)
axios.get(url[, config])
axios.delete(url[, config])
axios.head(url[, config])
axios.options(url[, config])
axios.post(url[, data[, config]])
axios.put(url[, data[, config]])
axios.patch(url[, data[, config]])

当使用别名方法时,url、method和data属性不需要在配置中指定

Creating an instance

创建一个自定义的实例

const instance = axios.create({baseURL: 'https://some-domain.com/api/',timeout: 1000,headers: {'X-Custom-Header': 'foobar'}
});

全局配置

模式每个请求都会按此配置

axios.defaults.baseURL = 'https://api.example.com';// Important: If axios is used with multiple domains, the AUTH_TOKEN will be sent to all of them.
// See below for an example using Custom instance defaults instead.
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

个性配置

// Set config defaults when creating the instance
const instance = axios.create({baseURL: 'https://api.example.com'
});// Alter defaults after instance has been created
instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;

请求配置参数

{// `url` is the server URL that will be used for the requesturl: '/user',// `method` is the request method to be used when making the requestmethod: 'get', // default// `baseURL` will be prepended to `url` unless `url` is absolute.// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs// to methods of that instance.baseURL: 'https://some-domain.com/api/',// `transformRequest` allows changes to the request data before it is sent to the server// This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE'// The last function in the array must return a string or an instance of Buffer, ArrayBuffer,// FormData or Stream// You may modify the headers object.transformRequest: [function (data, headers) {// Do whatever you want to transform the datareturn data;}],// `transformResponse` allows changes to the response data to be made before// it is passed to then/catchtransformResponse: [function (data) {// Do whatever you want to transform the datareturn data;}],// `headers` are custom headers to be sentheaders: {'X-Requested-With': 'XMLHttpRequest'},// `params` are the URL parameters to be sent with the request// Must be a plain object or a URLSearchParams objectparams: {ID: 12345},// `paramsSerializer` is an optional config in charge of serializing `params`paramsSerializer: {encode?: (param: string): string => { /* Do custom ops here and return transformed string */ }, // custom encoder function; sends Key/Values in an iterative fashionserialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ), // mimic pre 1.x behavior and send entire params object to a custom serializer func. Allows consumer to control how params are serialized.indexes: false // array indexes format (null - no brackets, false (default) - empty brackets, true - brackets with indexes)},// `data` is the data to be sent as the request body// Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'// When no `transformRequest` is set, must be of one of the following types:// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams// - Browser only: FormData, File, Blob// - Node only: Stream, Buffer, FormData (form-data package)data: {firstName: 'Fred'},// syntax alternative to send data into the body// method post// only the value is sent, not the keydata: 'Country=Brasil&City=Belo Horizonte',// `timeout` specifies the number of milliseconds before the request times out.// If the request takes longer than `timeout`, the request will be aborted.timeout: 1000, // default is `0` (no timeout)// `withCredentials` indicates whether or not cross-site Access-Control requests// should be made using credentialswithCredentials: false, // default// `adapter` allows custom handling of requests which makes testing easier.// Return a promise and supply a valid response (see lib/adapters/README.md).adapter: function (config) {/* ... */},// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.// This will set an `Authorization` header, overwriting any existing// `Authorization` custom headers you have set using `headers`.// Please note that only HTTP Basic auth is configurable through this parameter.// For Bearer tokens and such, use `Authorization` custom headers instead.auth: {username: 'janedoe',password: 's00pers3cret'},// `responseType` indicates the type of data that the server will respond with// options are: 'arraybuffer', 'document', 'json', 'text', 'stream'//   browser only: 'blob'responseType: 'json', // default// `responseEncoding` indicates encoding to use for decoding responses (Node.js only)// Note: Ignored for `responseType` of 'stream' or client-side requestsresponseEncoding: 'utf8', // default// `xsrfCookieName` is the name of the cookie to use as a value for xsrf tokenxsrfCookieName: 'XSRF-TOKEN', // default// `xsrfHeaderName` is the name of the http header that carries the xsrf token valuexsrfHeaderName: 'X-XSRF-TOKEN', // default// `onUploadProgress` allows handling of progress events for uploads// browser & node.jsonUploadProgress: function ({loaded, total, progress, bytes, estimated, rate, upload = true}) {// Do whatever you want with the Axios progress event},// `onDownloadProgress` allows handling of progress events for downloads// browser & node.jsonDownloadProgress: function ({loaded, total, progress, bytes, estimated, rate, download = true}) {// Do whatever you want with the Axios progress event},// `maxContentLength` defines the max size of the http response content in bytes allowed in node.jsmaxContentLength: 2000,// `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowedmaxBodyLength: 2000,// `validateStatus` defines whether to resolve or reject the promise for a given// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`// or `undefined`), the promise will be resolved; otherwise, the promise will be// rejected.validateStatus: function (status) {return status >= 200 && status < 300; // default},// `maxRedirects` defines the maximum number of redirects to follow in node.js.// If set to 0, no redirects will be followed.maxRedirects: 21, // default// `beforeRedirect` defines a function that will be called before redirect.// Use this to adjust the request options upon redirecting,// to inspect the latest response headers,// or to cancel the request by throwing an error// If maxRedirects is set to 0, `beforeRedirect` is not used.beforeRedirect: (options, { headers }) => {if (options.hostname === "example.com") {options.auth = "user:password";}},// `socketPath` defines a UNIX Socket to be used in node.js.// e.g. '/var/run/docker.sock' to send requests to the docker daemon.// Only either `socketPath` or `proxy` can be specified.// If both are specified, `socketPath` is used.socketPath: null, // default// `transport` determines the transport method that will be used to make the request. If defined, it will be used. Otherwise, if `maxRedirects` is 0, the default `http` or `https` library will be used, depending on the protocol specified in `protocol`. Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol, which can handle redirects.transport: undefined, // default// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http// and https requests, respectively, in node.js. This allows options to be added like// `keepAlive` that are not enabled by default.httpAgent: new http.Agent({ keepAlive: true }),httpsAgent: new https.Agent({ keepAlive: true }),// `proxy` defines the hostname, port, and protocol of the proxy server.// You can also define your proxy using the conventional `http_proxy` and// `https_proxy` environment variables. If you are using environment variables// for your proxy configuration, you can also define a `no_proxy` environment// variable as a comma-separated list of domains that should not be proxied.// Use `false` to disable proxies, ignoring environment variables.// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and// supplies credentials.// This will set an `Proxy-Authorization` header, overwriting any existing// `Proxy-Authorization` custom headers you have set using `headers`.// If the proxy server uses HTTPS, then you must set the protocol to `https`.proxy: {protocol: 'https',host: '127.0.0.1',// hostname: '127.0.0.1' // Takes precedence over 'host' if both are definedport: 9000,auth: {username: 'mikeymike',password: 'rapunz3l'}},// `cancelToken` specifies a cancel token that can be used to cancel the request// (see Cancellation section below for details)cancelToken: new CancelToken(function (cancel) {}),// an alternative way to cancel Axios requests using AbortControllersignal: new AbortController().signal,// `decompress` indicates whether or not the response body should be decompressed// automatically. If set to `true` will also remove the 'content-encoding' header// from the responses objects of all decompressed responses// - Node only (XHR cannot turn off decompression)decompress: true // default// `insecureHTTPParser` boolean.// Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers.// This may allow interoperability with non-conformant HTTP implementations.// Using the insecure parser should be avoided.// see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback// see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-noneinsecureHTTPParser: undefined // default// transitional options for backward compatibility that may be removed in the newer versionstransitional: {// silent JSON parsing mode// `true`  - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)// `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json')silentJSONParsing: true, // default value for the current Axios version// try to parse the response string as JSON even if `responseType` is not 'json'forcedJSONParsing: true,// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeoutsclarifyTimeoutError: false,},env: {// The FormData class to be used to automatically serialize the payload into a FormData objectFormData: window?.FormData || global?.FormData},formSerializer: {visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form valuesdots: boolean; // use dots instead of brackets formatmetaTokens: boolean; // keep special endings like {} in parameter keyindexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes},// http adapter only (node.js)maxRate: [100 * 1024, // 100KB/s upload limit,100 * 1024  // 100KB/s download limit]
}
Response Schema
The response for a request contains the following information.{// `data` is the response that was provided by the serverdata: {},// `status` is the HTTP status code from the server responsestatus: 200,// `statusText` is the HTTP status message from the server responsestatusText: 'OK',// `headers` the HTTP headers that the server responded with// All header names are lowercase and can be accessed using the bracket notation.// Example: `response.headers['content-type']`headers: {},// `config` is the config that was provided to `axios` for the requestconfig: {},// `request` is the request that generated this response// It is the last ClientRequest instance in node.js (in redirects)// and an XMLHttpRequest instance in the browserrequest: {}
}

响应参数

{// `data` is the response that was provided by the serverdata: {},// `status` is the HTTP status code from the server responsestatus: 200,// `statusText` is the HTTP status message from the server responsestatusText: 'OK',// `headers` the HTTP headers that the server responded with// All header names are lowercase and can be accessed using the bracket notation.// Example: `response.headers['content-type']`headers: {},// `config` is the config that was provided to `axios` for the requestconfig: {},// `request` is the request that generated this response// It is the last ClientRequest instance in node.js (in redirects)// and an XMLHttpRequest instance in the browserrequest: {}
}

拦截器

配置请求拦截器和响应拦截器(默认异步添加)

个性

const instance = axios.create();
instance.interceptors.request.use(function () {/*...*/});

全局

// Add a request interceptor
axios.interceptors.request.use(function (config) {// Do something before request is sentconfig.headers.test = 'I am only a header!';return config;}, function (error) {// Do something with request errorreturn Promise.reject(error);});// Add a response interceptor
axios.interceptors.response.use(function (response) {// Any status code that lie within the range of 2xx cause this function to trigger// Do something with response datareturn response;}, function (error) {// Any status codes that falls outside the range of 2xx cause this function to trigger// Do something with response errorreturn Promise.reject(error);});

同步方式添加拦截器

axios.interceptors.request.use(function (config) {config.headers.test = 'I am only a header!';return config;
}, null, { synchronous: true });

根据条件添加拦截器

function onGetCall(config) {return config.method === 'get';
}
axios.interceptors.request.use(function (config) {config.headers.test = 'special get headers';return config;
}, null, { runWhen: onGetCall });

删除拦截器

const myInterceptor = axios.interceptors.request.use(function () {/*...*/});
axios.interceptors.request.eject(myInterceptor);

清理拦截器

// Removes interceptors from requests
instance.interceptors.request.clear(); // Removes interceptors from responses
instance.interceptors.response.clear();

异常处理

默认情况下所有非 2xx 的返回,都认为是异常的


axios.get('/user/12345').catch(function (error) {if (error.response) {// The request was made and the server responded with a status code// that falls out of the range of 2xxconsole.log(error.response.data);console.log(error.response.status);console.log(error.response.headers);} else if (error.request) {// The request was made but no response was received// `error.request` is an instance of XMLHttpRequest in the browser and an instance of// http.ClientRequest in node.jsconsole.log(error.request);} else {// Something happened in setting up the request that triggered an Errorconsole.log('Error', error.message);}console.log(error.config);});

定义应该抛出错误的HTTP代码,默认是 (status >= 200 && status < 300)

 
axios.get('/user/12345', {validateStatus: function (status) {return status < 500; // Resolve only if the status code is less than 500}
})

中断请求

const controller = new AbortController();axios.get('/foo/bar', {signal: controller.signal
}).then(function(response) {//...
});
// cancel the request
controller.abort() 

使用 application/x-www-form-urlencoded 格式

axios 默认是json 格式提交数据,如果要使用表单格式(application/x-www-form-urlencoded),有以下2中方式:

  • 1、URLSearchParams
const params = new URLSearchParams({ foo: 'bar' });
params.append('extraparam', 'value');
axios.post('/foo', params);
  • 2、 qs
const qs = require('qs');
axios.post('/foo', qs.stringify({ 'bar': 123 }));

或者

import qs from 'qs';
const data = { 'bar': 123 };axios({method: 'POST',headers: { 'content-type': 'application/x-www-form-urlencoded' },data: qs.stringify(data),url,
});

若果数据头 content-type 设置为 “application/x-www-form-urlencoded” ,axios自动用表单方式提交数据

const data = {x: 1,arr: [1, 2, 3],arr2: [1, [2], 3],users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}],
};await axios.postForm('https://postman-echo.com/post', data,{headers: {'content-type': 'application/x-www-form-urlencoded'}}
);

数据将变成

  {x: '1','arr[]': [ '1', '2', '3' ],'arr2[0]': '1','arr2[1][0]': '2','arr2[2]': '3','arr3[]': [ '1', '2', '3' ],'users[0][name]': 'Peter','users[0][surname]': 'griffin','users[1][name]': 'Thomas','users[1][surname]': 'Anderson'}

使用 multipart/form-data 格式

FormData
使用 multipart/formdata 格式,需要用 FormData 对象做载体,axios 会自动设置headers: {‘content-type’: ‘multipart/form-data’}

const formData = new FormData();
formData.append('foo', 'bar');axios.post('https://httpbin.org/post', formData);

或者

axios.post('https://httpbin.org/post', {x: 1}, {headers: {'Content-Type': 'multipart/form-data'}
}).then(({data}) => console.log(data));

文件发送

提交单个文件

await axios.postForm('https://httpbin.org/post', {'myVar' : 'foo','file': document.querySelector('#fileInput').files[0]
});

使用 multipart/form-data 格式提交多个文件

await axios.postForm('https://httpbin.org/post', {'files[]': document.querySelector('#fileInput').files
});

或者

await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files)

速率限制

Download and upload rate limits can only be set for the http adapter (node.js):

const {data} = await axios.post(LOCAL_SERVER_URL, myBuffer, {onUploadProgress: ({progress, rate}) => {console.log(`Upload [${(progress*100).toFixed(2)}%]: ${(rate / 1024).toFixed(2)}KB/s`)},maxRate: [100 * 1024], // 100KB/s limit
});

相关文章:

聊聊 JSON Web Token (JWT) 和 jwcrypto 的使用

哈喽大家好,我是咸鱼。 最近写的一个 Python 项目用到了 jwcrypto 这个库,这个库是专门用来处理 JWT 的,JWT 全称是 JSON Web Token ,JSON 格式的 Token。 今天就来简单入门一下 JWT。官方介绍:https://jwt.io/introduction 先聊聊 Token Token 的意思是令牌,通常用于身份…...

CF1973E Cat, Fox and Swaps 题解

题意:对于一个长度为 \(n\) 的排列,求有多少对 \((l,r)\) 满足 \(1 \le l,r \le 2n\),且可以通过交换任意次 \(x,y(l \le x+y \le r)\) 使得原排列升序。首先...

HTML5画布-小球碰撞

Tips:当你看到这个提示的时候,说明当前的文章是由原emlog博客系统搬迁至此的,文章发布时间已过于久远,编排和内容不一定完整,还请谅解` HTML5画布-小球碰撞 日期:2017-7-18 阿珏 HTML 浏览:2465次 评论:2条html5是万维网的核心语言、标准通用标记语言下的一个应用超文…...

Hello Laravel! Laravel 入门教程

Hello Laravel! 准备 目录Hello Laravel! 准备什么是 Laravel?为什么选择 Laravel?优雅的语法丰富的功能强大的社区支持安全性易于扩展Laravel 的流行程度其他流行的 Web 框架对比环境准备下载 Laragon设置工作目录添加 PHP 版本设置环境变量Composer 安装初始化 Laravel 项目…...

【每周例题】判断回文串

判断回文串 题目 给你一个字符串 x ,如果 x 是一个回文字符串,返回 true ;否则,返回 false 。回文字符串是指正序(从左向右)和倒序(从右向左)读都是一样的。例如,aba 是回文,而 abc 不是。 代码#include<bits/stdc++.h> #include<cstring> using namespa…...

(10)uart串口通信

一、uart简介二、uart串口通信实验 其中:sys_clk为系统时钟。uart_rxd为串口从上位机接收到的数据,当检测到uart_rxd出现下降沿(起始位),start_flag产生正向脉冲,rx_flag也被拉高,clk_cnt为时钟计数器,由0计数到433,rx_cnt为接收数据计数器,当计数到第九位且时钟计数…...

axios使用

参考地址&#xff1a;https://github.com/axios/axios html CDN <script src"https://cdn.jsdelivr.net/npm/axios1.1.2/dist/axios.min.js"></script>或者 <script src"https://unpkg.com/axios1.1.2/dist/axios.min.js"></scrip…...

countup.js 数字动画

countup.js 数字动画1. 安装2. 参数3. Vue组件封装3.1 组件代码3.2 调用方式1. 安装 npm i countup.js2. 参数 项目Valuetargetstring, HTMLElement ,HTMLInputElement - id of html element, input, svg text element, or DOM element reference where counting occursendV…...

10个问题带你全面理解Linux性能优化

1. 为什么面试官喜欢考察性能优化问题&#xff1f; 面试官考察性能优化问题的目的可能并不是要你设计一个性能很高的系统&#xff0c;而是为了全方位考察一个面试者的知识背景和实践能力。 1) 性能优化涉及的知识面既需要深度&#xff0c;同时又需要一定的广度 从深度上来说…...

php使用yield处理大数据文件

1.概述 yield和return有点像&#xff0c;它是一个生成器&#xff0c;对PHP应用的性能有非常大的影响&#xff0c; 只有在调用的时候才会执行&#xff0c;并不产生多余的值&#xff0c;比如读取一个很大的文件或者计算大量的数据时&#xff0c;如果直接读取很有可能内存就爆了&a…...

数据更新 | CnOpenData法拍房数据

法拍房数据 一、数据简介 法拍房&#xff0c;即“法院拍卖房产”&#xff0c;是被法院强制执行拍卖的房屋 。当债务人&#xff08;业主&#xff09;无力履行借款合约或无法清偿债务时&#xff0c;而被债权人经司法程序向法院申请强制执行&#xff0c;将债务人名下房屋拍卖&…...

(一)kafka从入门到精通之初识kafka

一、发布订阅系统 在学习kafka之前&#xff0c;我们先来看看什么是发布订阅系统。 概念 数据的发送者不会直接把消息发送给接收者&#xff0c;这是发布与订阅消息系统的一个特点。发布者以某种方式对消息进行分类&#xff0c;接受者订阅它们&#xff0c;以便接受特定类型的消…...

stata17中double类型与float类型的区别(变量的存储格式和显示格式、数值运算出错、转换数值格式、字符型数据转换为数值型数据)

double类型与float类型区别 参考&#xff1a;变量的存储格式和显示格式 数值运算出错 因为营业总收入和其他业务收入都是字符型数据&#xff0c;所以使用real函数将其转换为数值型数据。 gen 主营业务收入 real(营业总收入)-real(其他业务收入)结果如下图所示&#xff1a;计…...

【JVS低代码配置平台】基于树形字典的纯配置实现左树右表

左树右表是我们在业务管理系统中常见的业务形态&#xff0c;如下图所示&#xff0c;树形结构用于多层级的数据的展示&#xff0c;列表页作为对应数据的横向行级展现。 实现树形的配置有两种模式&#xff0c;一种是根据树形字典配置&#xff08;简单导入即可&#xff09;&#x…...

Spring Boot实现Redis同数据源动态切换DB | Spring Cloud 31

一、前言 在某些业务场景下&#xff0c;需要多访问同一Redis数据源下的不同DB。 在Redis中默认提供了16个数据库&#xff08;序号0-15&#xff09;&#xff0c;默认Redis使用的是db 0。 此章节基于spring-boot-starter-data-redis模块&#xff0c;实现了Redis同数据源动态切换…...

[技术经理]02 什么是技术经理?

目录01什么是技术经理02总结01什么是技术经理 什么是技术经理&#xff1f; 我用一句话概括为&#xff1a;专业技术团队的管理者。 技术经理&#xff0c;是一种管理职位&#xff0c;通常是在软件开发、互联网等科技公司或技术团队中担任。 技术经理的职责&#xff0c;**是管理…...

油炸食品的最佳用油:米糠油

摘要&#xff1a;本文详细介绍了米糠油作为最佳油炸用油的各种特点&#xff0c;但更重要的是建议采用真空油炸方法&#xff0c;更能发挥米糠油的优势。 油炸食品是我们日常生活中常见的美味&#xff0c;人们普遍的共识是“油炸食品虽然好吃&#xff0c;但不适合多吃”&#xff…...

【C++】queue和priority_queue的成员函数和非成员函数

目录 1. queue 1.1 queue的成员函数 1.1.1 构造函数 1.1.2 判空 1.1.3 大小 1.1.4 队头 1.1.5 队尾 1.1.6 入队 1.1.7 emplace 1.1.8 出队 1.1.9 交换 1.2 queue的非成员函数 1.2.1 关系运算符重载 1.2.2 交换 2. priority_queue 2.1 priority_queue的成员函数…...

韩长赋在第七届杭州全球企业家论坛开幕式上讲话

今天我们相聚在美丽的西子湖畔&#xff0c;隆重举办“第七届杭州全球企业家论坛暨中国消费品博览会”&#xff0c;旨在凝聚发展力量&#xff0c;共创合作未来。 今年是全面贯彻落实党的二十大精神的开局之年&#xff0c;是全面建设社会主义现代化国家&#xff0c;加快建设农业强…...

webpack+nginx开启gzip压缩部署项目

首先在服务器安装nginx sudo apt update sudo apt install nginx 安装完毕后将前端项目打包 webpack.output.publicPath里配置资源基础路径 资源打包出来就是/publicPath开头 1.http://www.xxx.com/ publicPath: / 2.http://www.xxx.com/web publicPath: /web/ 尾巴多加个/…...

coco 2017数据集 类别提取并转换为yolo数据集

coco 2017数据集提取和转换本次分割的动物数据集 4G一. coco2017数据集结构标注文件解析二. 提取需要的类别重新封装成coco数据集&#xff08;这里以动物类别为例&#xff09;三. 转换为yolo 数据集本次分割的动物数据集 4G https://download.csdn.net/download/qq_26696715/8…...

jdk线程池技术

jdk线程池ThreadPoolExecutor的7个参数 public ThreadPoolExecutor(int corePoolSize,int maximumPoolSize,long keepAliveTime,TimeUnit unit,BlockingQueue<Runnable> workQueue,ThreadFactory threadFactory,RejectedExecutionHandler handler) {if (corePoolSize &l…...

keepalived+nginx 双机热备搭建

keepalivednginx 双机热备搭建一、准备工作1.1 准备两台centos7.91.2 nginx 与 keepalived软件 双机安装1.3 ip分配1.4 修改主机名1.5 关闭selinux&#xff08;双机执行&#xff09;1.6 修改hosts&#xff08;双机执行&#xff09;二、安装keepalived2.1 执行一下命令安装keepa…...

【云原生】容器编排技术Docker Compose

为什么需要Docker ComposeDocker Compose介绍Docker Compose安装Docker Compose版本介绍Docker Compose基本命令介绍Docker Compose实战Docker Compose Yml文件介绍总结为什么需要Docker Compose Docker帮助我们解决服务的打包安装的问题&#xff0c;随着而来的问题就是服务过…...

String、StringBuilder、StringBuffer的四大区别解析

面试官问&#xff1a;String、StringBuilder、StringBuffer有什么区别么&#xff1f; 这个问题是个高频问题&#xff0c;所以今天从源码上进行深度刨析他们的区别。 如何回答&#xff1a; 从四个点出发&#xff1a; 1、可变/不可变类 String是不可变类。他被被final修饰&…...

【C#进阶】C# 匿名方法

序号系列文章18【C#进阶】C# 事件19【C#进阶】C# 集合类20【C#进阶】C# 泛型文章目录前言1、什么是匿名方法&#xff1f;2、delegate 运算符3、Lambda 表达式3.1、Lambda 表达式的自然类型3.2、Lambda 表达式的显示返回类型4、关于匿名方法的总结结语前言 &#x1f4fa; hello大…...

C++并发编程之二 在线程间共享数据

文章目录1.1 互斥锁&#xff08;mutex&#xff09;保护共享数据1.1.1 std::mutex 的成员函数 std::mutex::lock() 和std::mutex::unlock() (不推荐使用)1.1.2 使用std::lock_guard保护共享数据1.1.3 使用std::unique_lock保护共享数据1.2 保护共享数据的其他方式1.2.1 初始化过…...

FL Studio和Cubase哪个容易一些 FL Studio和Cubase修音哪个好

FL Studio和Cubase哪个容易一些&#xff1f;FL Studio是很适合新手使用的宿主软件。FL Studio和Cubase修音哪个好&#xff1f;FL Studio和Cubase在修音方面各有千秋。 一、FL Studio和Cubase哪个容易一些 FL Studio是很适合新手上手的宿主软件&#xff0c;这得益于FL Studio独…...

限定学校|在站博士后省公派新加坡国立大学从事博后研究

Y博士为国内在站博士后&#xff0c;我们向其推荐了人社部博管办国外博士后派出项目及所在省的相关项目&#xff0c;最终助其获得新加坡国立大学的博士后邀请函&#xff0c;鉴于该导师名列全球高被引科学家榜单&#xff0c;顺利获批省国际培养博士后资助项目&#xff0c;如期出国…...

信息技术最全总结(备考教资)

信息技术 备考教资信息技术知识点总结&#xff0c;欢迎收藏&#xff01;需要xmind和备考书籍的可以评论区留言。 第一部分-学科专业知识 第一章-信息技术基础知识 信息与信息技术概述 信息概述 信息的定义 信息本身不是实体信息是通过文字、数字、图像、图形、声音、视频等方…...

spring5(三):IOC操作Bean管理(基于xml方式)

IOC操作Bean管理&#xff08;基于xml方式&#xff09;前言一、基于 xml 方式创建对象二、基于 xml 方式注入属性1. 使用 set 方法进行属性注入2. 使用有参数构造进行属性注入3. p 名称空间注入简化操作&#xff08;了解&#xff09;三、xml 注入其它类型属性1. 字面量2. 注入属…...

Vue的快速上手

一、创建一个 Vue 应用 前提条件 熟悉命令行已安装 16.0 或更高版本的 Node.js在本篇中&#xff0c;我们将介绍如何在本地搭建 Vue 单页应用。创建的项目将使用基于 Vite 的构建设置&#xff0c;并允许我们使用 Vue 的单文件组件 (SFC)。 确保你安装了最新版本的 Node.js&…...

通过ELK+kafka采集微服务日志

在springboot微服务中采集日志推送kafka背景整体流程图快速搭建kafkazk开发环境通过logback记录日志到kafka快速搭建ELK环境Kibana查看&#xff0c;统计日志背景 在分布式的项目中&#xff0c;各功能模块产生的日志比较分散&#xff0c;同时为满足性能要求&#xff0c;同一个微…...

开启新航路,拓尔思发力AIGC市场 | 爱分析调研

2022年&#xff0c;随着AI聊天机器人GhatGPT在世界范围内持续火爆&#xff0c;极具创意、表现力、个性化且能快速迭代的AIGC技术成功破圈&#xff0c;成为全民讨论热点。 AIGC是指在确定主题下&#xff0c;由算法模型自动生成内容&#xff0c;包括单模态内容如文本、图像、音频…...

01-死磕QNX someip

1. vsomeip3.1.20版本 环境配置 export COMMONAPI_CONFIG/etc/commonapi.ini export LD_LIBRARY_PATH/sdcard/someip:$LD_LIBRARY_PATH export VSOMEIP_CONFIGURATION/etc/vsomeip-service.json export VSOMEIP_APPLICATION_NAMEHelloWorldSomeIPService sysctl -w net.ine…...

OTFS输入输出关系

目录 1. OTFS输入输出关系的矩阵表示 1.1 OTFS&#xff1a;矩阵表示 1.2 OTFS发射机的实现 1.2.1 传统的OTFS调制 ISFFT 海森堡变换 1.2.2 基于IDZT的OTFS调制 1.3 OTFS接收机的实现 1.3.1 传统的OTFS解调 维格纳变换 SFFT 1.3.2 基于DZT的OTFS解调 Appendix-Matlab C…...

Java的抽象类和接口

目录 一 、抽象类 1、抽象类概念 2、抽象类语法 3、抽象类特性 4、抽象类的作用 二、接口 1、接口的概念 2、语法规则 3、接口使用 4、接口特性 5、实现多个接口 6、接口间的继承 7、抽象类和接口的区别 8、接口使用实例 9、Clonable 接口和深拷贝 三、Object类…...

作为一个女测试员是什么样的体验?

面试时极度紧张&#xff0c;语无伦次&#xff0c;觉得肯定没戏&#xff0c;最后却拿到高薪offer。 工作之后我听同事们讲&#xff0c;测试总监面试官并没打算要我&#xff0c;但身边的人都问他&#xff1a; 那个小姐姐什么时候来报道&#xff1f;... 于是在众人的期待的目光…...

移动端 REM 适配

Vant 中的样式默认使用 px 作为单位&#xff0c;如果需要使用 rem 单位&#xff0c;推荐使用以下两个工具&#xff1a; postcss-pxtorem 是一款 postcss 插件&#xff0c;用于将单位转化为 rem lib-flexible 用于设置 rem 基准值 下面我们分别将这两个工具配置到项目中完成 R…...

哈希表【leetcode】

笔记&#xff1a;代码随想录 理论 概念 哈希表&#xff08;hash table&#xff0c;散列表&#xff09;&#xff1a;是根据关键码的值而直接访问的数据结构&#xff0c;说白&#xff0c;数组就是一张哈希表。 哈希函数&#xff1a;把变量直接映射为表上的索引。 哈希碰撞&a…...

【Gem5】有关gem5模拟器的资料导航

网上有关gem5模拟器的资料、博客良莠不齐&#xff0c;这里记录一些总结的很好的博客与自己的学习探索。 一、gem5模拟器使用入门 官方的教程&#xff1a; learning_gem5&#xff1a;包括gem5简介、修改扩展gem5的示例、Ruby相关的缓存一致性等。gem5 Documentation&#xff1…...

R语言中apply系列函数详解

文章目录applylapply, sapply, vapplyrapplytapplymapplyR语言的循环效率并不高&#xff0c;所以并不推荐循环以及循环嵌套。为了实现循环功能的情况下&#xff0c;兼顾效率&#xff0c;R语言提供了apply系列函数&#xff0c;用于对规则的数据进行函数式的迭代处理。 apply a…...

AOP的另类用法 (权限校验自定义注解)

&#x1f473;我亲爱的各位大佬们好&#x1f618;&#x1f618;&#x1f618; ♨️本篇文章记录的为 AOP的另类用法 (权限校验&&自定义注解) 相关内容&#xff0c;适合在学Java的小白,帮助新手快速上手,也适合复习中&#xff0c;面试中的大佬&#x1f649;&#x1f649…...

【机器学习】机器学习建模调参方法总结

文章目录一、前言1.1 数据来源1.2 理论简介二、知识总结2.1 回归分析2.2 长尾分布2.3 欠拟合与过拟合2.4 正则化2.5 调参方法2.5.1 贪心调参 &#xff08;坐标下降&#xff09;2.5.2 网格调参GridSearchCV2.5.3 贝叶斯调参三、建模与调参3.1 线性回归3.1.1 模型建立3.1.2 查看训…...

Python数据分析师|Pandas之基础知识

版权声明&#xff1a;原创不易&#xff0c;本文禁止抄袭、转载&#xff0c;侵权必究&#xff01; 目录一、数据分析简介二、数据分析简介三、数据查看四、知识总结五、作者Info一、数据分析简介 随着科技的发展&#xff0c;数据变得尤为重要&#xff0c;甚至有着“数据为王”&…...

macOS 13.3(22E252)/12.6.4/11.7.5正式版发布

系统介绍 3 月 28 日消息&#xff0c;苹果今日向 Mac 电脑用户推送了 macOS 13.3 更新&#xff08;内部版本号&#xff1a;22E252&#xff09;苹果今天还发布了macOS Monterey 12.6.4和macOS Big Sur 11.7.5&#xff0c;本次更新距离上次发布隔了 42 天。 macOS Ventura 带来…...

速度与兼容性功能大比拼:7款浏览器测评,哪一款更好用

还在为使用哪款浏览器而发愁吗&#xff1f;电脑配置低&#xff0c;又想浏览网页顺畅、下载速度快&#xff0c;那么就要挑选功能齐全、速度快的浏览器。话不多说&#xff0c;给大家做了7款浏览器的最全测评&#xff0c;看看2023年哪个浏览器更好用&#xff0c;更适合自己。 本次…...

【建议收藏】2023年中高级软件测试大厂面试秘籍,为你保驾护航金三银四,直通大厂

前言 从几十份顶级面试仓库和300多篇高质量面经中总结出一份全面成体系化的软件测试高级面试题集。 随着软件测试岗位技术发展的成熟&#xff0c;自动化、性能、框架等一下子就进入了我们的视野内&#xff0c;同时&#xff0c;软件测试自身的技术栈也正在不断扩展&#xff0c…...

Cinema 4D 2023.1.3安装包下载及安装教程

[软件名称]:Cinema 4D 2023.1.3 [软件大小]: 1.0GB [安装环境]: Win11/Win 10 [软件安装包下载]: https://pan.quark.cn/s/c2324deaa028 CINEMA 4D字面意思是4D电影&#xff0c;不过其本身就是3D的表现软件&#xff0c;由德国Maxon Computer开发&#xff0c;以极高的运算速度和…...

IDEA vs Eclipse:使用体验对比

1. 概述 IDEA 和 Eclipse 都是常见的集成开发环境&#xff08;IDE&#xff09;&#xff0c;用于编写和调试代码。它们都有一些共同的功能&#xff0c;例如代码编辑器、调试器、版本控制等等。但是在具体的使用体验上&#xff0c;它们有很多不同之处。 本文将对 IDEA 和 Eclip…...

新手学SpringCloud前需知道的5点

目录 第一点&#xff1a; 什么是微服务架构 第二点&#xff1a;为什么需要学习Spring Cloud 第三点&#xff1a; Spring Cloud 是什么 第四点&#xff1a; SpringCloud的优缺点 1、SpringCloud优点 2、SpringCloud缺点 第五点&#xff1a; SpringCloud由什么组成 1&…...

Java集合—HashMap为什么2倍扩容 、HashMap的key允许空值而Hashtable却不允许

目录 1. Java集合—HashMap为什么2倍扩容 1.1 从源码分析 2. 为什么HashMap的key允许空值&#xff0c;而Hashtable却不允许 2.1 从源码分析 1. Java集合—HashMap为什么2倍扩容 HashMap的初始容量都是2的n次幂的形式存在的&#xff0c;而扩容也是2倍的原来的容量进行扩容&a…...

国内、外(翻)的新闻网站推荐

也许有很多朋友和我一样&#xff0c;小小螺丝天天关注国家大事&#xff0c;总喜欢在茶余饭后关注下国内外新闻&#xff0c;除了新闻广播和电视之外还能有哪些方式呢&#xff1f;今天就给大家盘点总结一下。 一、国内 1.今日头条&#xff1a;链接&#xff1a;今日头条 推荐等…...

PHP初级教程------------------(2)

目录 运算符 赋值运算符 算术运算符 比较运算符 逻辑运算符 连接运算符 错误抑制符 三目运算符 自操作运算符 ​编辑 计算机码 位运算符 运算符优先级 流程控制 控制分类 顺序结构 分支结构 If分支 ​ Switch分支 循环结构 For循环 while循环 do-while循环 循环控制 ​ …...

js的递归函数——实现可收放的树形菜单

递归函数实现树形菜单创建假数据或者请求接口数据定义递归函数&#xff0c;处理数据调用函数&#xff0c;渲染页面效果展示完整代码树形菜单是一种常见的网站导航方式&#xff0c;它通常由多个层级的菜单项组成&#xff0c;每个菜单项可以有子菜单项。在JavaScript中&#xff0…...

如何高效搭建资产管理平台?众安科技告诉你答案是图技术

本⽂整理⾃ NebulaGraph x 阿⾥云计算巢专场中众安保险的⼤数据应⽤⾼级专家曾⼒带来的《众安资产在 NebulaGraph 的应⽤实践》分享&#xff0c;视频⻅链接。 ⼤家好&#xff0c;我是众安数据科学应⽤中⼼的曾⼒&#xff0c;今天很⾼兴在这⾥可以跟⼤家分享 NebulaGraph 在众安…...

解密!从传统纹样里,读懂东方审美

纹样,是文化的图案密码,它在中国传统文化中无处不在,而在东盟国家,也有着独特的文化特征和审美趣味。广西同东盟国家地缘相近、人缘相亲、文缘相通,文化交流交融的历史源远流长,广西与东盟国家的纹样有着许多相似之处。文物无声,纹样有色。2024年5月18日是第48个“国际博…...

出行注意!受降雨影响 深圳铁路部分普速列车停运

本文转自【央视新闻客户端】;广东省已启动防汛Ⅳ级应急响应。为应对暴雨可能对铁路运输带来的影响,国铁广州局从5月18日起,对深圳境内途经京广、京九等线路的普速列车采取调整运行区段,由深圳始发,途经这两条线路的部分列车停运。截至今天上午9时,已累计停运普速旅客列车…...

管理Kubernetes平台的工具Rancher

目录 一、特性二、使用方法2.1、安装 Rancher2.2、创建 Kubernetes 集群2.3、管理和部署应用 Rancher 是一个开源的容器管理平台&#xff0c;它提供了企业级的 Kubernetes 管理解决方案&#xff0c;使得部署和管理 Kubernetes 集群变得更加简单。Rancher 提供了一个统一的控制面…...

Redis-Redis事务

Redis事务 Redis事务简介 Redis事务是一组命令的集合&#xff0c;一个事务中的所有命令都将被序列化&#xff0c;按照一次性、顺序性、排他 性的执行队列系列的命令。Redis单条命令保证原子性&#xff0c;但是事务不保证原子性&#xff0c;且没有回滚。事务中任意命令执行失败…...

【oracle】图片转为字节、base64编码等形式批量插入oracle数据库并查询

1.熟悉、梳理、总结下Oracle相关知识体系 2.欢迎批评指正&#xff0c;跪谢一键三连&#xff01; 资源下载&#xff1a; oci.dll、oraocci11.dll、oraociei11.dll3个资源文件资源下载&#xff1a; Instant Client Setup.exe资源下载&#xff1a; oci.dll、oraocci11.dll、oraoc…...

Python--常见运算符

在编程中&#xff0c;赋值运算符、比较运算符以及逻辑运算符是基础而重要的概念之一。它们在处理变量赋值、数据比较和逻辑操作时发挥着关键作用。了解它们的功能和使用方法对于编写清晰、有效的代码至关重要。让我们逐一了解这些运算符的作用及示例。 1. 赋值运算符 赋值运算…...

文字游侠AI丨简直是写作神器,头条爆文一键生成稳定赚米!附渠道和详细教程(只需四步)!

在数字时代的浪潮中&#xff0c;人们不断寻求网络空间中的商机&#xff0c;期望在互联网的浩瀚海洋里捕捉到稳定的财富。随着人工智能技术的突飞猛进&#xff0c;越来越多的AI工具被融入到各行各业&#xff0c;开辟了新天地&#xff0c;带来了创新的盈利模式。 其中&#xff0c…...

0.98T优于10米高程DEM数据

我们在《全球30米100%水陆覆盖高程》一文中&#xff0c;为大家分享了全球100%覆盖&#xff0c;且包括海底高程的30米DEM数据。 该数据虽然全球无死角覆盖&#xff0c;但分辨率只有30米。 这里&#xff0c;再为大家分享一个优于10米的高程数据&#xff0c;但目前仅覆盖全国范围…...

OpenAI GPT-4o:开启人工智能交互新纪元

引言 在人工智能领域&#xff0c;OpenAI一直是创新的代名词。2024年5月14日&#xff0c;OpenAI再次以GPT-4o模型震撼了科技界&#xff0c;这款全新的旗舰生成模型不仅免费向公众开放&#xff0c;更以其革命性的多模态交互能力&#xff0c;引领我们进入了一个全新的科幻时代。 …...

CV每日论文--2024.5.15

1、Can Better Text Semantics in Prompt Tuning Improve VLM Generalization? 中文标题&#xff1a;更好的文本语义在提示微调中能否提高视觉语言模型的泛化能力? 简介&#xff1a;这篇论文介绍了一种新的可学习提示调整方法,该方法超越了仅对视觉语言模型进行微调的传统方…...

GIT基础02 多机器协作等命令

前言 首先我们知道git给我们提供了分支管理的功能 我们一般使用master分支作为线上环境,master分支一般是一个稳定的分支 我们通常是会创建一个其他分支进行开发,这样不会影响线上的机器运行 如果没有git提供这样的分支功能,就无法做到这一套了 指令学习 假设软件出现问题咋办…...

界面组件DevExpress WPF v23.2 - 全新升级的数据编辑器、流程图组件

DevExpress WPF拥有120个控件和库&#xff0c;将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpress WPF能创建有着强大互动功能的XAML基础应用程序&#xff0c;这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案。 DevExpress WPF控件日…...