摘要:
问题:实现一个TS方法,多个字符转或者多个数字相加 首先会想到用泛型实现 例如 let sum = <T>(a: T, b: T): T => a + b 但是这样会报 “运算符+不可用于类型T” 接下来我们可能会想到给类型T加上限制 type SunType = string | number; 阅读全文
摘要:
Vue指令的钩子如下 bind:只调用一次,指令第一次绑定到元素时调用,用这个钩子函数可以定义一个绑定时执行一次的初始化动作。 inserted:被绑定元素插入父节点时调用(父节点存在即可调用,不必存在于document中)。 update:被绑定于元素所在的模板更新时调用,而无论绑定值是否变化。通 阅读全文
摘要:
css之弹出层居中, container设置为fixed,并且覆盖整个屏幕, 设置半透明 container的底下一层设置为absolute,然后top/left设置为50%居中,这个时候这层的左上角剧中了,然后用 transform再退回50%,把container的底下一层的中心居于屏幕中心 . 阅读全文
摘要:
为某些类型添加扩展方法,比如C#的数组原先没有Join 把数组拼接成字符串,具体请参考JS的join。 下面代码为 IEnumerable<T>添加 Join, 为Object添加Keys public static class Extends { /// <summary> /// 把值类型的数组 阅读全文
摘要:
自定义自己的特性方法 MyCustom [AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Method, Inherited = true, AllowMultiple = true) 阅读全文
摘要:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace 阅读全文
摘要:
type WithPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; interface RequestOption { url: string, method: 'GET' | 'POST' | 'PUT', head 阅读全文
摘要:
// two.jsexport default { bind(el, binding, vnode){ console.log(binding); el.value = binding.value if (/\.async/.test(binding.rawName)) { el.onchange 阅读全文
摘要:
下面这是运行起来的页面,这里可以看到API请求后的response,也可以设置status来选择命中不同的response,设置timeout让API模拟延时。 下面是添加在 package的devDependencies mock的github地址 "mock": "git+https://git 阅读全文
摘要:
vue实例化的参数 计算属性 computed 我们可以使用 methods 来替代 computed,效果上两个都是一样的,但是 computed 是基于它的依赖缓存,只有相关依赖发生改变时才会重新取值。而使用 methods ,在重新渲染的时候,函数总会重新调用执行。 prop 是父组件用来传递 阅读全文