vue-class-component
人的教养不能够靠别人传授,人必须进行自我修养。一切苦修也绝不是文化修养,教育是通过人的主动性来实现的,教育牢牢地钉在主动性上。——费希特 官方文档:https://class-component.vuejs.org/ class-component是vue官方库之一,其可以让你使用class的方式定义、编写组件 再加上ts的装饰器,最终效果如下: 12345678910111213141516171819202122232425262728<template> <div> <button v-on:click="decrement">-</button> {{ count }} <button v-on:click="increment">+</button> </div></template><script>import Vue from 'vue'...
泛型限定问题
双木非林,田下有心。——顾城 首先看这段代码: 12345678910111213141516171819202122import java.util.function.Function;class Scratch { static class RoleInfo { } public static void main(String[] args) { // 想让这两个通过 test(Object::hashCode, RoleInfo::hashCode, new RoleInfo()); test(Object::toString, RoleInfo::toString, new RoleInfo()); // 想让这个报错 test(Object::hashCode, RoleInfo::toString, new RoleInfo()); } public static <T, A, R> void te...
teleport
你之前学了啥跟你以后能学啥没有什么本质联系——尤雨溪 顾名思义,teleport汉译过来就是传送的意思 官方文档:https://v3.cn.vuejs.org/guide/teleport.html#teleport 它可以将我们的元素传送到指定地点: 例如我们要实现一个挂载在body上的模态框,就可以使用teleport: 12345678910111213141516171819202122232425262728const app = Vue.createApp({});app.component('modal-button', { template: ` <button @click="modalOpen = true"> Open full screen modal! (With teleport!) </button> <teleport to="body"> <div v-if=&quo...
vue3组合式api
自由自由,多少罪恶假汝之名以行。——罗兰夫人 这个思想上有点类似流程控制框架,将一个组件中的多个关注点分离、抽取,然后能进一步复用、编排 官方文档:https://v3.cn.vuejs.org/guide/composition-api-introduction.html#%E4%BB%8B%E7%BB%8D 使用上来讲,就是编写的api方式变了,举个例子: 下面是我实际写的一个小组件 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657<script lang="tsx">interface Props { msg: string; msgModifiers: { [key: string]: boolean; };}import { computed, onMounted, ref, Ref, toRefs, watch,...
vue3配置jsx
正如自然忌讳真空一样,人类是讨厌平等的。——《我是猫》 首先按照官方文档创建项目: 1npm init vite hello-vue3 -- --template vue # 或 yarn create vite hello-vue3 --template vue 然后我们安装jsx插件:https://github.com/vuejs/babel-plugin-jsx 1npm install @vue/babel-plugin-jsx -D 然后配置vite.config.js 123456789101112import { defineConfig } from 'vite'import vue from '@vitejs/plugin-vue'import vuejsx from "@vue/babel-plugin-jsx"// https://vitejs.dev/config/export default defineConfig({ plugins: [vue(),...
Collectors.flatMapping
我只想站在比你高的地方,用人类最纯粹的痛苦和烦恼给你一记响亮的耳光。——《阴火》 发现官方竟然没有,那就自己写一个 12345678910public static <T, U, A, R>Collector<T, ?, R> flatMapping(Function<? super T, Stream<? extends U>> mapper, Collector<? super U, A, R> downstream) { BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator(); return new Collectors.CollectorImpl<>(downstream.supplier(), (r, t) -> Opp.ofNullable(t).map(mapper).ifPres...
escape、unescape废弃
爱所有人,信任少数人,不负任何人。——莎士比亚 今天看到这个API废弃了,提示使用 encodeURI 或 encodeURIComponent 代替。 但是貌似有部分符号并没有转义成功 最后在示例看到了解决办法 123456789101112131415161718192021222324252627282930var fileName = 'my file(2).txt';var header = "Content-Disposition: attachment; filename*=UTF-8''" + encodeRFC5987ValueChars(fileName);console.log(header);// 输出 "Content-Disposition: attachment; filename*=UTF-8''my%20file%282%29.txt"function encodeRFC5987ValueChars (str) ...
StreamEx
这个世界上没有无用的齿轮,也只有齿轮本身能决定自己的用途。——《嫌疑犯X的献身》 跟昨天介绍的eclipse-collections一样,这是一个同类产品: 仓库地址:https://github.com/amaembo/streamex JavaDoc:http://amaembo.github.io/streamex/javadoc/one/util/streamex/package-summary.html 感受下: 123List<String> userNames = StreamEx.of(users).map(User::getName).toList();Map<Role, List<User>> role2users = StreamEx.of(users).groupingBy(User::getRole);StreamEx.of(1,2,3).joining("; "); // "1; 2; 3" 对比起来好像比eclipse-collections写更少代码 而且更向原生s...
eclipse-collections
志向和热爱是伟大行为的双翼。——歌德 之前分享了vavr,今天在分享一个同类框架eclipse-collections 官方文档:http://www.eclipse.org/collections/ 1234567891011<dependency> <groupId>org.eclipse.collections</groupId> <artifactId>eclipse-collections-api</artifactId> <version>11.0.0</version></dependency><dependency> <groupId>org.eclipse.collections</groupId> <artifactId>eclipse-collections</artifactId> <version>11.0.0</version></dependency&...
List<Map>聚合为单个Map<List>
科学是到处为家的,不过,在任何不播种的地方,是决不会得到丰收的。——赫尔岑 前两天有人给我的项目stream-query提交了PR,新增了一个Collector实现 我稍微研究了一下,发现与Collectors原生命名风格不统一,且不具备Collectors包下面的对象通用性,于是就移除了 但这个功能是可以保留的 我的实现如下: 1234567891011121314151617181920212223242526@Testvoid testReducing() { Set<Map<String, Integer>> nameScoreMapList = Stream.of( new HashMap<String, Integer>() {{ put("苏格拉底", 1); put("特拉叙马霍斯", 3); }}, Co...
