Posts
All the articles I've posted.
-
【前后端异常】http/https 请求返回415错误状态码
一、问题描述 二、错误原因 以下解释来源 MDN : 415 Unsupported Media Type 是一种 HTTP 协议的错误状态代码,表示服务器由于不支持其有效载荷的格式,从而拒绝接受客户端的请求。 具体原因:请求头中未携带 ”Content-Type“ 或与接口注解不一致 三、解决方案 针对我遇到的问题,前端在请求头中添加 ”Content-Type“:
at 02:27(Updated) -
angular实现类似Vue中的slot用法
方案一:Directive item.directive.ts import { Input , Directive , TemplateRef , EmbeddedViewRef , ViewContainerRef , } from '@angular/core' ; @ Directive ({ selector : '[ListItem]' , }) export class ListItem { private _context : any ; private _viewRef : EmbeddedViewRef < any >; constructor ( private viewContainer : ViewContainerRef , public templateRef : TemplateRef < any > ) { this . _viewRef = this . viewContainer . createEmbeddedView ( templateRef ); } @ Input ()
at 03:07(Updated) -
TCP与UDP
UDP 面向报文 UDP 是一个面向报文(报文可以理解为一段段的数据)的协议。意思是 UDP 只是报文的搬运工,不会对报文进行任何拆分和拼接操作。 具体来说 在发送端,应用层将数据传递给传输层的 UDP 协议,UDP 只会给数据增加一个 UDP 头标识下是 UDP 协议,然后就传递给网络层了 在接收端,网络层将数据传递给传输层,UDP 只去除 IP 报文头就传递给应用层,不会有任何拼接操作 不可靠性 UDP 是无连接的,也就是说通信不需要建立和断开连接 UDP 也是不可靠的,协议收到什么数据就传递什么数据,并且也不会备份数据,
at 14:17(Updated) -
Vue2使用slot跨组件传递信息
父组件 Parent.vue < template > < div class = "parent" > < Child > < span # slot1 = " { item , index } " >{{ index }}</ span > < span # slot2 = " { item , index } " >{{ index }}</ span > </ Child > </ div > </ template > < script > import Child from './Child.vue' export default { name : "parent" } </ script > Parent.jsx import Child from './Child.jsx' const Parent = Vue . component ( 'parent' , { render ()
at 14:34(Updated) -
Vue2 与 Vue3
生命周期 Vue2.x Vue3.x beforeCreate setup created setup beforeMount onBeforeMount mounted onMounted beforeUpdate onBeforeUpdate updated onUpdated beforeDestroy onBeforeUnmount destroyed onUnmounted errorCaptured onErrorCaptured 整体来看变化不大,除了 beforeCreate 、 created 用 setup 代替外,其余的基本都是变更名称,但功能本质上未发生变化 响应式原理 Object.defineProperty vue2 中无法实现对数组对象的深层监听,是因为组件每次渲染都是将 data 里的数据通过 defineProperty 进行响应式或者双向绑定,
at 02:36