Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
5a19f513
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看板
提交
5a19f513
编写于
4月 23, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(directive): v-once
上级
cee5edba
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
110 addition
and
26 deletion
+110
-26
pages.json
pages.json
+14
-8
pages/directive/v-once/v-once-composition.uvue
pages/directive/v-once/v-once-composition.uvue
+22
-0
pages/directive/v-once/v-once-options.uvue
pages/directive/v-once/v-once-options.uvue
+30
-0
pages/directive/v-once/v-once.test.js
pages/directive/v-once/v-once.test.js
+22
-14
pages/index/index.uvue
pages/index/index.uvue
+19
-1
refactor_options-API-composition-API-correspondence.md
refactor_options-API-composition-API-correspondence.md
+3
-3
未找到文件。
pages.json
浏览文件 @
5a19f513
...
...
@@ -201,6 +201,20 @@
"navigationBarTitleText"
:
"v-pre"
}
},
//
#ifdef
APP
{
"path"
:
"pages/directive/v-once/v-once-options"
,
"style"
:
{
"navigationBarTitleText"
:
"v-once 选项式 API"
}
},
{
"path"
:
"pages/directive/v-once/v-once-composition"
,
"style"
:
{
"navigationBarTitleText"
:
"v-once 组合式 API"
}
},
//
#endif
{
...
...
@@ -265,14 +279,6 @@
"navigationBarTitleText"
:
"v-model"
}
},
//
#ifdef
APP
{
"path"
:
"pages/directive/v-once/v-once"
,
"style"
:
{
"navigationBarTitleText"
:
"v-once"
}
},
//
#endif
{
"path"
:
"pages/directive/v-memo/v-memo"
,
"style"
:
{
...
...
pages/directive/v-once/v-once-composition.uvue
0 → 100644
浏览文件 @
5a19f513
<template>
<view class="page">
<view class="flex flex-row justify-between mb-10" v-once>
<text>This msg will never change:</text>
<text id='v-once-msg'>{{ msg }}</text>
</view>
<view class="flex flex-row justify-between mb-10">
<text>msg:</text>
<text id="msg">{{ msg }}</text>
</view>
<button id="btn" class="mb-10" type="primary" @click="changeMessage">
change message
</button>
</view>
</template>
<script setup lang="uts">
const msg = ref('hello world')
const changeMessage = () => {
msg.value = 'msg changed'
}
</script>
pages/directive/v-once/v-once.uvue
→
pages/directive/v-once/v-once
-options
.uvue
浏览文件 @
5a19f513
<template>
<view class="page">
<view class="split-title">v-once</view>
<text class="uni-common-mt v-once-text" v-once>This will never change: {{ msg }}</text>
<text class="uni-common-mt">msg: {{msg}}</text>
<button class="uni-common-mt btn" type="primary" @click="changeMessage">change message</button>
<view class="flex flex-row justify-between mb-10" v-once>
<text>This msg will never change:</text>
<text id='v-once-msg'>{{ msg }}</text>
</view>
<view class="flex flex-row justify-between mb-10">
<text>msg:</text>
<text id="msg">{{ msg }}</text>
</view>
<button id="btn" class="mb-10" type="primary" @click="changeMessage">
change message
</button>
</view>
</template>
...
...
pages/directive/v-once/v-once.test.js
浏览文件 @
5a19f513
const
PAGE_PATH
=
'
/pages/directive/v-once/v-once
'
const
OPTIONS_PAGE_PATH
=
'
/pages/directive/v-once/v-once-options
'
const
COMPOSITION_PAGE_PATH
=
'
/pages/directive/v-once/v-once-composition
'
describe
(
'
v-once
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
...
...
@@ -9,22 +10,29 @@ describe('v-once', () => {
return
}
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
const
test
=
async
(
pagePath
)
=>
{
page
=
await
program
.
reLaunch
(
pagePath
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
const
vOnceTextEl
=
await
page
.
$
(
'
.v-once-text
'
)
let
vOnceTextText
=
await
vOnceTextEl
.
text
()
expect
(
vOnceTextText
).
toBe
(
'
This will never change: hello world
'
)
const
vOnceMsg
=
await
page
.
$
(
'
#v-once-msg
'
)
expect
(
await
vOnceMsg
.
text
()).
toBe
(
'
hello world
'
)
const
msg
=
await
page
.
$
(
'
#msg
'
)
expect
(
await
msg
.
text
()).
toBe
(
'
hello world
'
)
const
btn
=
await
page
.
$
(
'
.
btn
'
)
const
btn
=
await
page
.
$
(
'
#
btn
'
)
await
btn
.
tap
()
const
msg
=
await
page
.
data
(
'
msg
'
)
expect
(
msg
).
toBe
(
'
msg changed
'
)
vOnceTextText
=
await
vOnceTextEl
.
text
()
expect
(
vOnceTextText
).
toBe
(
'
This will never change: hello world
'
)
expect
(
await
vOnceMsg
.
text
()).
toBe
(
'
hello world
'
)
expect
(
await
msg
.
text
()).
toBe
(
'
msg changed
'
)
}
it
(
'
v-once options API
'
,
async
()
=>
{
await
test
(
OPTIONS_PAGE_PATH
)
})
it
(
'
v-once composition API
'
,
async
()
=>
{
await
test
(
COMPOSITION_PAGE_PATH
)
})
})
\ No newline at end of file
pages/index/index.uvue
浏览文件 @
5a19f513
...
...
@@ -719,7 +719,25 @@ export default {
id: 'v-pre',
name: 'v-pre',
url: 'v-pre/v-pre'
}
},
// #ifdef APP
{
id: 'v-once',
name: 'v-once',
children: [
{
id: 'v-once-options',
name: 'v-once 选项式 API',
url: 'v-once-options'
},
{
id: 'v-once-composition',
name: 'v-once 组合式 API',
url: 'v-once-composition'
},
]
},
// #endif
]
},
{
...
...
refactor_options-API-composition-API-correspondence.md
浏览文件 @
5a19f513
...
...
@@ -161,11 +161,11 @@ function transform(fileInfo, api) {
-
[ ] v-bind
-
[ ] v-model
-
[ ] v-slot
-
[
] v-pre
-
[
] v-once
-
[
x
] v-pre
-
[
x
] v-once
-
[ ] v-memo
-
[ ] v-text
-
[ ]
-cloak
-
[ ]
v-cloak 暂不支持
## lifecycle
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录