veaury
没有意义的事物是最美丽的。——《新名字的故事》 昨天分享了vuera 今天再分享一个同类型库veaury,属于是vuera的新版库 中文文档:https://github.com/devilwjp/veaury/blob/master/README_zhcn.md 什么是Veaury?Veaury 是基于React和Vue3的工具库,主要用于React和Vue在一个项目中公共使用的场景,主要运用在项目迁移、技术栈融合的开发模式、跨技术栈使用第三方组件的场景。 重要功能 🌞 支持 Vue3 🌈 支持 Context - 同一个应用中出现的vue组件和react组件的context是共享的. 💗 支持跨框架的hooks调用 - 可以在react组件中使用vue的hooks,获取到vue组件或者应用的上下文数据,比如vue-router、vuex,也可以在vue组件中使用react的hooks,获取到react组件或者应用的上下文数据,比如react-router、provide、context等
vuera
微微怪时间不能保存情绪,保存那一切情绪所曾流连的境界。——《你是人间的四月天》 分享一个开源项目:https://github.com/akxcv/vuera 它可以让你在vue里写react,在react里写vue Use Vue components in your React app: 1234567import React from 'react'import MyVueComponent from './MyVueComponent.vue'export default props => <div> <MyVueComponent message={props.message} handleReset={props.handleReset} /> </div> Or use React components in your Vue app: 1234567891011121314<template> <div&g...
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...
