上篇文章主要是对尤雨溪在 2025 vue.js nation 大会的分享内容总结。分享中提到 vue3.6 将会使用 alien-signals
替换 proxy
响应式系统。
今天我们仔细盘盘 alien-signals
。
alien-signals
基本用法
alien-signals
是一个非常轻量级的响应式信号系统库,提供了标准的响应式三件套:signal
、computed
、effect
。
上篇文章主要是对尤雨溪在 2025 vue.js nation 大会的分享内容总结。分享中提到 vue3.6 将会使用 alien-signals
替换 proxy
响应式系统。
今天我们仔细盘盘 alien-signals
。
alien-signals
基本用法alien-signals
是一个非常轻量级的响应式信号系统库,提供了标准的响应式三件套:signal
、computed
、effect
。
上篇文章《🚀🚀🚀Vapor Mode 发布前,你应该知道的一些事情!》根据自己的经验,对 3.6 版本的改变做了一些预测!
响应式API
!VNode
组件级渲染方案为精确的真实dom
渲染!今天,我们一起来看看 2025
年 1月3号
的vue.js nation
大会上尤雨溪的报告内容了!
这篇文章主要是完善上篇文章部署服务器的部分,由于最近刚买了服务器,所以才有了今天的内容。废话不多说,下面是正文。
文章同步在公众号:萌萌哒草头将军,欢迎关注
在服务器或者其他电脑生成一堆ssh
密钥对,命令如下:
欢迎关注我的公众号:萌萌哒草头将军
入口->全局初始化->生成 vnode->挂载
入口函数
export const createApp = (...args) => {
// 1.创建实例
const app = ensureRenderer().createApp(...args);
// 2. 重写实例的 mount 方法
const { mount } = app;
app.mount = (containerOrSelector) => {
const container = normalizeContainer(containerOrSelector);
if (!container) return;
const component = app._component;
if (!isFunction(component) && !component.render && !component.template) {
// __UNSAFE__
// Reason: potential execution of JS expressions in in-DOM template.
// The user must make sure the in-DOM template is trusted. If it's
// rendered by the server, the template should not contain any user data.
component.template = container.innerHTML;
// 2.x compat check
if (__COMPAT__ && __DEV__) {
for (let i = 0; i < container.attributes.length; i++) {
const attr = container.attributes[i];
if (attr.name !== "v-cloak" && /^(v-|:|@)/.test(attr.name)) {
compatUtils.warnDeprecation(
DeprecationTypes.GLOBAL_MOUNT_CONTAINER,
null
);
break;
}
}
}
}
// clear content before mounting
container.innerHTML = "";
const proxy = mount(container, false, resolveRootNamespace(container));
if (container instanceof Element) {
container.removeAttribute("v-cloak");
container.setAttribute("data-v-app", "");
}
return proxy;
};
return app;
};
文章同步在公众号:萌萌哒草头将军,欢迎关注
文章同步在公众号:萌萌哒草头将军,欢迎关注
今天继续上次的内容,使用hook封装几种的异步请求函数场景。
我们期望的场景是,
文章同步在公众号:萌萌哒草头将军,欢迎关注。
今天分享几个上千⭐的库,助你玩转React学习和开发。
git地址:https://github.com/sudheerj/reactjs-interview-questions
文章首发公众号:萌萌哒草头将军,欢迎关注
最近想体验下自定义指令功能,看了看文档和 vue2 差异不大,语法如下:
const myDirective = {
// 在绑定元素的 attribute 前
// 或事件监听器应用前调用
created(el, binding, vnode, prevVnode)
{ // 下面会介绍各个参数的细节 },
// 在元素被插入到 DOM 前调用
beforeMount(el, binding, vnode, prevVnode) {},
// 在绑定元素的父组件
// 及他自己的所有子节点都挂载完成后调用
mounted(el, binding, vnode, prevVnode) {},
// 绑定元素的父组件更新前调用
beforeUpdate(el, binding, vnode, prevVnode) {},
// 在绑定元素的父组件
// 及他自己的所有子节点都更新后调用
updated(el, binding, vnode, prevVnode) {},
// 绑定元素的父组件卸载前调用
beforeUnmount(el, binding, vnode, prevVnode) {},
// 绑定元素的父组件卸载后调用
unmounted(el, binding, vnode, prevVnode) {} }
文章同步在公众号:萌萌哒草头将军,欢迎关注
js中媒体查询的主要方法是使用window对象下的matchMedia
对象,查询语句和CSS媒体查询一样。
首先我们先看监听系统主题色的例子
export const useTheme = () => {
// 首先创建媒体查询对象
const themeMedia = matchMedia("(prefers-color-scheme: light)")
// 根据查询结果设置对应的值
const theme = ref(themeMedia.matches ? 'light' : 'dark')
const onChange = (e: MediaQueryListEvent) => theme.value = e.matches ? 'light' : 'dark'
watchEffect((onCleanup) => {
// 然后建立监听事件
themeMedia.addEventListener('change', onChange)
// 并且在退出时取消监听
onCleanup(() => themeMedia.removeEventListener('change', onChange))
})
return theme;
}
最新文章发布在公众号:
萌萌哒草头将军
,个人:SunBoy_mmdctjj
,欢迎关注,最近关注有🎁,送五本JavaScript的书~
Vue3.3
已经发布一个月了,今天我和大家体验下最新功能
创建完项目后记得下载最新的包
// 创建
npm create vite vue-demo --template vue-ts
// 下载依赖
cd vue-demo
npm i
// 更新到最新版本
npm i vue@3.3
// 运行
npm run dev