Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
88e65d34
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
350
Star
2
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uvue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
88e65d34
编写于
1月 18, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
types: 类型优化
上级
5a25e308
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
17 addition
and
17 deletion
+17
-17
pages/composition-api/reactivity/watch-effect/watch-effect.uvue
...composition-api/reactivity/watch-effect/watch-effect.uvue
+4
-4
pages/composition-api/reactivity/watch-post-effect/watch-post-effect.uvue
...n-api/reactivity/watch-post-effect/watch-post-effect.uvue
+4
-4
pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect.uvue
...n-api/reactivity/watch-sync-effect/watch-sync-effect.uvue
+4
-4
pages/composition-api/reactivity/watch/watch.uvue
pages/composition-api/reactivity/watch/watch.uvue
+5
-5
未找到文件。
pages/composition-api/reactivity/watch-effect/watch-effect.uvue
浏览文件 @
88e65d34
...
@@ -50,9 +50,9 @@
...
@@ -50,9 +50,9 @@
const watchCountTrackNum = ref(0)
const watchCountTrackNum = ref(0)
const watchCountTriggerNum = ref(0)
const watchCountTriggerNum = ref(0)
const stopWatchCount = watchEffect((onCleanup: OnCleanup) => {
const stopWatchCount = watchEffect((onCleanup
: OnCleanup) => {
if (countRef.value !== null) {
if (countRef.value !== null) {
watchCountRes.value = `count: ${count.value}, count ref text (flush sync): ${
(countRef.value as UniElement)
.getAttribute('value')}`
watchCountRes.value = `count: ${count.value}, count ref text (flush sync): ${
countRef.value!
.getAttribute('value')}`
} else {
} else {
watchCountRes.value = `count: ${count.value}, count ref text (flush sync): `
watchCountRes.value = `count: ${count.value}, count ref text (flush sync): `
}
}
...
@@ -99,7 +99,7 @@
...
@@ -99,7 +99,7 @@
const watchObjStrRes = ref('')
const watchObjStrRes = ref('')
watchEffect(() => {
watchEffect(() => {
if (objStrRef.value !== null) {
if (objStrRef.value !== null) {
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text (flush pre): ${
(objStrRef.value as UniElement)
.getAttribute('value')}`
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text (flush pre): ${
objStrRef.value!
.getAttribute('value')}`
} else {
} else {
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text (flush pre): `
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text (flush pre): `
}
}
...
@@ -112,7 +112,7 @@
...
@@ -112,7 +112,7 @@
const watchObjBoolRes = ref('')
const watchObjBoolRes = ref('')
watchEffect(() => {
watchEffect(() => {
if (objBoolRef.value !== null) {
if (objBoolRef.value !== null) {
watchObjBoolRes.value = `bool: ${obj.bool}, obj.bool ref text (flush post): ${
(objBoolRef.value as UniElement)
.getAttribute('value')}`
watchObjBoolRes.value = `bool: ${obj.bool}, obj.bool ref text (flush post): ${
objBoolRef.value!
.getAttribute('value')}`
} else {
} else {
watchObjBoolRes.value = `bool: ${obj.bool}, obj.bool ref text (flush post): `
watchObjBoolRes.value = `bool: ${obj.bool}, obj.bool ref text (flush post): `
}
}
...
...
pages/composition-api/reactivity/watch-post-effect/watch-post-effect.uvue
浏览文件 @
88e65d34
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
arr : number[]
arr : number[]
}
}
const countRef = ref(null)
const countRef = ref
<UniElement | null>
(null)
const count = ref<number>(0)
const count = ref<number>(0)
const watchCountRes = ref('')
const watchCountRes = ref('')
const watchCountCleanupRes = ref('')
const watchCountCleanupRes = ref('')
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
const stopWatchCount = watchPostEffect((onCleanup : OnCleanup) => {
const stopWatchCount = watchPostEffect((onCleanup : OnCleanup) => {
if (countRef.value !== null) {
if (countRef.value !== null) {
watchCountRes.value = `count: ${count.value}, count ref text: ${
(countRef.value as Element)
.getAttribute('value')}`
watchCountRes.value = `count: ${count.value}, count ref text: ${
countRef.value!
.getAttribute('value')}`
} else {
} else {
watchCountRes.value = `count: ${count.value}, count ref text: `
watchCountRes.value = `count: ${count.value}, count ref text: `
}
}
...
@@ -94,11 +94,11 @@
...
@@ -94,11 +94,11 @@
watchObjRes.value = `obj: ${JSON.stringify(obj)}`
watchObjRes.value = `obj: ${JSON.stringify(obj)}`
})
})
const objStrRef = ref(null)
const objStrRef = ref
<UniElement | null>
(null)
const watchObjStrRes = ref('')
const watchObjStrRes = ref('')
watchPostEffect(() => {
watchPostEffect(() => {
if (objStrRef.value !== null) {
if (objStrRef.value !== null) {
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text: ${
(objStrRef.value as Element)
.getAttribute('value')}`
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text: ${
objStrRef.value!
.getAttribute('value')}`
} else {
} else {
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text: `
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text: `
}
}
...
...
pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect.uvue
浏览文件 @
88e65d34
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
arr : number[]
arr : number[]
}
}
const countRef = ref(null)
const countRef = ref
<UniElement | null>
(null)
const count = ref(0)
const count = ref(0)
const watchCountRes = ref('')
const watchCountRes = ref('')
const watchCountCleanupRes = ref('')
const watchCountCleanupRes = ref('')
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
const stopWatchCount = watchSyncEffect((onCleanup : OnCleanup) => {
const stopWatchCount = watchSyncEffect((onCleanup : OnCleanup) => {
if (countRef.value !== null) {
if (countRef.value !== null) {
watchCountRes.value = `count: ${count.value}, count ref text: ${
(countRef.value as Element)
.getAttribute('value')}`
watchCountRes.value = `count: ${count.value}, count ref text: ${
countRef.value!
.getAttribute('value')}`
} else {
} else {
watchCountRes.value = `count: ${count.value}, count ref text: `
watchCountRes.value = `count: ${count.value}, count ref text: `
}
}
...
@@ -94,11 +94,11 @@
...
@@ -94,11 +94,11 @@
watchObjRes.value = `obj: ${JSON.stringify(obj)}`
watchObjRes.value = `obj: ${JSON.stringify(obj)}`
})
})
const objStrRef = ref(null)
const objStrRef = ref
<UniElement | null>
(null)
const watchObjStrRes = ref('')
const watchObjStrRes = ref('')
watchSyncEffect(() => {
watchSyncEffect(() => {
if (objStrRef.value !== null) {
if (objStrRef.value !== null) {
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text: ${
(objStrRef.value as Element)
.getAttribute('value')}`
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text: ${
objStrRef.value!
.getAttribute('value')}`
} else {
} else {
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text: `
watchObjStrRes.value = `str: ${obj.str}, obj.str ref text: `
}
}
...
...
pages/composition-api/reactivity/watch/watch.uvue
浏览文件 @
88e65d34
...
@@ -50,8 +50,8 @@
...
@@ -50,8 +50,8 @@
const watchCountTrackNum = ref(0)
const watchCountTrackNum = ref(0)
const watchCountTriggerNum = ref(0)
const watchCountTriggerNum = ref(0)
const stopWatchCount = watch(count, (count : number, prevCount : number, onCleanup: OnCleanup) => {
const stopWatchCount = watch(count, (count : number, prevCount : number, onCleanup
: OnCleanup) => {
watchCountRes.value = `count: ${count}, prevCount: ${prevCount}, count ref text (flush sync): ${
(countRef.value as UniElement)
.getAttribute('value')}`
watchCountRes.value = `count: ${count}, prevCount: ${prevCount}, count ref text (flush sync): ${
countRef.value!
.getAttribute('value')}`
const cancel = () => {
const cancel = () => {
watchCountCleanupRes.value = `watch count cleanup: ${count}`
watchCountCleanupRes.value = `watch count cleanup: ${count}`
}
}
...
@@ -88,14 +88,14 @@
...
@@ -88,14 +88,14 @@
// immediate: true 第一次触发, 旧值应该是 undefined, 现在 app 是初始值
// immediate: true 第一次触发, 旧值应该是 undefined, 现在 app 是初始值
const watchObjRes = ref('')
const watchObjRes = ref('')
watch(obj, (obj : Obj, prevObj
?: Obj) => {
watch(obj, (obj : Obj, prevObj?: Obj) => {
watchObjRes.value = `obj: ${JSON.stringify(obj)}, prevObj: ${JSON.stringify(prevObj)}`
watchObjRes.value = `obj: ${JSON.stringify(obj)}, prevObj: ${JSON.stringify(prevObj)}`
}, { immediate: true })
}, { immediate: true })
const objStrRef = ref<UniElement | null>(null)
const objStrRef = ref<UniElement | null>(null)
const watchObjStrRes = ref('')
const watchObjStrRes = ref('')
watch(() : string => obj.str, (str : string, prevStr : string) => {
watch(() : string => obj.str, (str : string, prevStr : string) => {
watchObjStrRes.value = `str: ${str}, prevStr: ${prevStr}, obj.str ref text (flush pre): ${
(objStrRef.value as UniElement)
.getAttribute('value')}`
watchObjStrRes.value = `str: ${str}, prevStr: ${prevStr}, obj.str ref text (flush pre): ${
objStrRef.value!
.getAttribute('value')}`
}, {
}, {
// 侦听器在组件渲染之前触发
// 侦听器在组件渲染之前触发
flush: 'pre',
flush: 'pre',
...
@@ -104,7 +104,7 @@
...
@@ -104,7 +104,7 @@
const objBoolRef = ref<UniElement | null>(null)
const objBoolRef = ref<UniElement | null>(null)
const watchObjBoolRes = ref('')
const watchObjBoolRes = ref('')
watch(() : boolean => obj.bool, (bool : boolean, prevBool : boolean) => {
watch(() : boolean => obj.bool, (bool : boolean, prevBool : boolean) => {
watchObjBoolRes.value = `bool: ${bool}, prevBool: ${prevBool}, obj.bool ref text (flush post): ${
(objBoolRef.value as UniElement)
.getAttribute('value')}`
watchObjBoolRes.value = `bool: ${bool}, prevBool: ${prevBool}, obj.bool ref text (flush post): ${
objBoolRef.value!
.getAttribute('value')}`
}, {
}, {
// 侦听器延迟到组件渲染之后触发
// 侦听器延迟到组件渲染之后触发
flush: 'post'
flush: 'post'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录