Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
be734f3d
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
347
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看板
提交
be734f3d
编写于
4月 22, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 移除无用文件
上级
90c33bc6
变更
24
显示空白变更内容
内联
并排
Showing
24 changed file
with
0 addition
and
612 deletion
+0
-612
pages/composition-api/basic/define-emits/array-literal.uvue
pages/composition-api/basic/define-emits/array-literal.uvue
+0
-14
pages/composition-api/basic/define-emits/define-emits.test.js
...s/composition-api/basic/define-emits/define-emits.test.js
+0
-37
pages/composition-api/basic/define-emits/define-emits.uvue
pages/composition-api/basic/define-emits/define-emits.uvue
+0
-40
pages/composition-api/basic/define-emits/type-emits-1.uvue
pages/composition-api/basic/define-emits/type-emits-1.uvue
+0
-16
pages/composition-api/basic/define-emits/type-emits-2.uvue
pages/composition-api/basic/define-emits/type-emits-2.uvue
+0
-17
pages/composition-api/basic/define-model/Foo.uvue
pages/composition-api/basic/define-model/Foo.uvue
+0
-22
pages/composition-api/basic/define-model/define-model.test.js
...s/composition-api/basic/define-model/define-model.test.js
+0
-34
pages/composition-api/basic/define-model/define-model.uvue
pages/composition-api/basic/define-model/define-model.uvue
+0
-31
pages/composition-api/basic/define-options/define-options.test.js
...mposition-api/basic/define-options/define-options.test.js
+0
-25
pages/composition-api/basic/define-options/define-options.uvue
.../composition-api/basic/define-options/define-options.uvue
+0
-35
pages/composition-api/basic/define-props/array-literal.uvue
pages/composition-api/basic/define-props/array-literal.uvue
+0
-15
pages/composition-api/basic/define-props/define-props.test.js
...s/composition-api/basic/define-props/define-props.test.js
+0
-64
pages/composition-api/basic/define-props/define-props.uvue
pages/composition-api/basic/define-props/define-props.uvue
+0
-26
pages/composition-api/basic/define-props/object-literal.uvue
pages/composition-api/basic/define-props/object-literal.uvue
+0
-34
pages/composition-api/basic/define-props/type-props.uvue
pages/composition-api/basic/define-props/type-props.uvue
+0
-22
pages/composition-api/basic/define-slots/Foo.uvue
pages/composition-api/basic/define-slots/Foo.uvue
+0
-19
pages/composition-api/basic/define-slots/define-slots.test.js
...s/composition-api/basic/define-slots/define-slots.test.js
+0
-19
pages/composition-api/basic/define-slots/define-slots.uvue
pages/composition-api/basic/define-slots/define-slots.uvue
+0
-19
pages/composition-api/basic/use-attrs/Foo.uvue
pages/composition-api/basic/use-attrs/Foo.uvue
+0
-19
pages/composition-api/basic/use-attrs/use-attrs.test.js
pages/composition-api/basic/use-attrs/use-attrs.test.js
+0
-16
pages/composition-api/basic/use-attrs/use-attrs.uvue
pages/composition-api/basic/use-attrs/use-attrs.uvue
+0
-10
pages/composition-api/basic/use-slots/Foo.uvue
pages/composition-api/basic/use-slots/Foo.uvue
+0
-34
pages/composition-api/basic/use-slots/use-slots.test.js
pages/composition-api/basic/use-slots/use-slots.test.js
+0
-27
pages/composition-api/basic/use-slots/use-slots.uvue
pages/composition-api/basic/use-slots/use-slots.uvue
+0
-17
未找到文件。
pages/composition-api/basic/define-emits/array-literal.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<text class="bold">array literal</text>
<button class="array-literal-emit-btn uni-common-mt" @click="emitChange">emit change</button>
</view>
</template>
<script setup>
const emit = defineEmits(['change'])
const emitChange = () => {
emit('change', 1)
}
</script>
\ No newline at end of file
pages/composition-api/basic/define-emits/define-emits.test.js
已删除
100644 → 0
浏览文件 @
90c33bc6
const
PAGE_PATH
=
'
/pages/composition-api/basic/define-emits/define-emits
'
describe
(
'
defineEmits
'
,
()
=>
{
let
page
=
null
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
const
handleArrayLiteralChangeRes
=
await
page
.
$
(
'
#handle-array-literal-change-res
'
)
expect
((
await
handleArrayLiteralChangeRes
.
text
()).
trim
()).
toBe
(
'
handle array literal comp change result:
'
)
const
arrayLiteralEmitBtn
=
await
page
.
$
(
'
.array-literal-emit-btn
'
)
await
arrayLiteralEmitBtn
.
tap
()
expect
(
await
handleArrayLiteralChangeRes
.
text
()).
toBe
(
'
handle array literal comp change result: options is 1
'
)
const
handleTypeEmits1ChangeRes
=
await
page
.
$
(
'
#handle-type-emits1-change-res
'
)
expect
((
await
handleTypeEmits1ChangeRes
.
text
()).
trim
()).
toBe
(
'
handle type emits comp change result:
'
)
const
typeEmits1EmitBtn
=
await
page
.
$
(
'
.type-emits1-emit-btn
'
)
await
typeEmits1EmitBtn
.
tap
()
expect
(
await
handleTypeEmits1ChangeRes
.
text
()).
toBe
(
'
handle type emits comp change result: options is 2
'
)
const
handleTypeEmits2ChangeRes
=
await
page
.
$
(
'
#handle-type-emits2-change-res
'
)
expect
((
await
handleTypeEmits2ChangeRes
.
text
()).
trim
()).
toBe
(
'
handle type emits named tuple syntax comp change result:
'
)
const
typeEmits2EmitBtn
=
await
page
.
$
(
'
.type-emits2-emit-btn
'
)
await
typeEmits2EmitBtn
.
tap
()
expect
(
await
handleTypeEmits2ChangeRes
.
text
()).
toBe
(
'
handle type emits named tuple syntax comp change result: options is 3
'
)
})
})
\ No newline at end of file
pages/composition-api/basic/define-emits/define-emits.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="page">
<ArrayLiteral @change='handleArrayLiteralCompChange' />
<text id="handle-array-literal-change-res" class="uni-common-mt">handle array literal comp change result:
{{handleArrayLiteralCompChangeRes}}</text>
<TypeEmits1 @change='handleTypeEmits1CompChange' />
<text id="handle-type-emits1-change-res" class="uni-common-mt">handle type emits comp change result:
{{handleTypeEmits1CompChangeRes}}</text>
<TypeEmits2 @change='handleTypeEmits2CompChange' />
<text id="handle-type-emits2-change-res" class="uni-common-mt">handle type emits named tuple syntax comp change
result: {{handleTypeEmits2CompChangeRes}}</text>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script setup>
import ArrayLiteral from './array-literal.uvue';
import TypeEmits1 from './type-emits-1.uvue';
import TypeEmits2 from './type-emits-2.uvue';
const handleArrayLiteralCompChangeRes = ref('')
const handleArrayLiteralCompChange = (num : number) => {
handleArrayLiteralCompChangeRes.value = `options is ${num}`
}
const handleTypeEmits1CompChangeRes = ref('')
const handleTypeEmits1CompChange = (num : number) => {
handleTypeEmits1CompChangeRes.value = `options is ${num}`
}
const handleTypeEmits2CompChangeRes = ref('')
const handleTypeEmits2CompChange = (num : number) => {
handleTypeEmits2CompChangeRes.value = `options is ${num}`
}
</script>
\ No newline at end of file
pages/composition-api/basic/define-emits/type-emits-1.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<text class="uni-common-mt bold">type emits</text>
<button class="type-emits1-emit-btn uni-common-mt" @click="emitChange">emit change</button>
</view>
</template>
<script setup>
const emit = defineEmits<{
(e : 'change', id : number) : void
}>()
const emitChange = () => {
emit('change', 2)
}
</script>
\ No newline at end of file
pages/composition-api/basic/define-emits/type-emits-2.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<text class="uni-common-mt bold">type emits named tuple syntax</text>
<button class="type-emits2-emit-btn uni-common-mt" @click="emitChange">emit change</button>
</view>
</template>
<script setup>
const emit = defineEmits<{
// 具名元组语法
change : [id: number]
}>()
const emitChange = () => {
emit('change', 3)
}
</script>
\ No newline at end of file
pages/composition-api/basic/define-model/Foo.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<text id="model-value-text">modelValue in Foo: {{modelValue}}</text>
<text class='uni-common-mt' id="msg-text">msg in Foo: {{msg}}</text>
<text class='uni-common-mt' id="default-num-text">num: {{defaultNum}}</text>
<button class='uni-common-mt' id="update-value-btn" @click='updateValue'>update value</button>
</view>
</template>
<script setup>
// 在被修改时,触发 "update:modelValue" 事件
const modelValue = defineModel({ type: String })
// 在被修改时,触发 "update:msg" 事件
const msg = defineModel('msg', { type: String, default: 'default msg' })
const defaultNum = defineModel('num', { type: Number, default: 10 })
const updateValue = () => {
modelValue.value += '1'
msg.value += '2'
}
</script>
\ No newline at end of file
pages/composition-api/basic/define-model/define-model.test.js
已删除
100644 → 0
浏览文件 @
90c33bc6
const
PAGE_PATH
=
'
/pages/composition-api/basic/define-model/define-model
'
describe
(
'
defineModel
'
,
()
=>
{
let
page
=
null
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
const
modelValueText
=
await
page
.
$
(
'
#model-value-text
'
)
expect
(
await
modelValueText
.
text
()).
toBe
(
'
modelValue in Foo: str
'
)
const
modelValueInput
=
await
page
.
$
(
'
#model-value-input
'
)
expect
(
await
modelValueInput
.
value
()).
toBe
(
'
str
'
)
const
msgText
=
await
page
.
$
(
'
#msg-text
'
)
expect
(
await
msgText
.
text
()).
toBe
(
'
msg in Foo: msg
'
)
const
defaultNumText
=
await
page
.
$
(
'
#default-num-text
'
)
expect
(
await
defaultNumText
.
text
()).
toBe
(
'
num: 10
'
)
const
msgInput
=
await
page
.
$
(
'
#msg-input
'
)
expect
(
await
msgInput
.
value
()).
toBe
(
'
msg
'
)
const
updateValueBtn
=
await
page
.
$
(
'
#update-value-btn
'
)
await
updateValueBtn
.
tap
()
expect
(
await
modelValueText
.
text
()).
toBe
(
'
modelValue in Foo: str1
'
)
expect
(
await
modelValueInput
.
value
()).
toBe
(
'
str1
'
)
expect
(
await
msgText
.
text
()).
toBe
(
'
msg in Foo: msg2
'
)
expect
(
await
msgInput
.
value
()).
toBe
(
'
msg2
'
)
})
})
\ No newline at end of file
pages/composition-api/basic/define-model/define-model.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view class="page">
<Foo v-model='str' v-model:msg="msg" @update:modelValue="handleModelValueUpdate" @update:msg="handleMsgUpdate" />
<input class='uni-common-mt input' id="model-value-input" v-model="str" />
<input class='uni-common-mt input' id="msg-input" v-model="msg" />
</view>
</template>
<script setup>
import Foo from './Foo.uvue'
const str = ref('str')
const msg = ref('msg')
const handleModelValueUpdateRes = ref('')
const handleModelValueUpdate = (val : string) => {
handleModelValueUpdateRes.value = `new str value: ${val}`
}
const handleMsgUpdateRes = ref('')
const handleMsgUpdate = (val : string) => {
handleMsgUpdateRes.value = `new msg value: ${val}`
}
</script>
<style>
.input {
padding: 8px 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
</style>
\ No newline at end of file
pages/composition-api/basic/define-options/define-options.test.js
已删除
100644 → 0
浏览文件 @
90c33bc6
const
PAGE_PATH
=
'
/pages/composition-api/basic/define-options/define-options
'
describe
(
'
defineOptions
'
,
()
=>
{
let
page
=
null
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
const
count
=
await
page
.
$
(
'
#count
'
)
expect
(
await
count
.
text
()).
toBe
(
'
count: 0
'
)
const
doubleCount
=
await
page
.
$
(
'
#double-count
'
)
expect
(
await
doubleCount
.
text
()).
toBe
(
'
double count: 0
'
)
const
total
=
await
page
.
$
(
'
#total
'
)
expect
(
await
total
.
text
()).
toBe
(
'
total: 0
'
)
const
incrementBtn
=
await
page
.
$
(
'
.increment-btn
'
)
await
incrementBtn
.
tap
()
expect
(
await
count
.
text
()).
toBe
(
'
count: 1
'
)
expect
(
await
doubleCount
.
text
()).
toBe
(
'
double count: 2
'
)
const
price
=
await
page
.
data
(
'
price
'
)
expect
(
await
total
.
text
()).
toBe
(
`total:
${
1
*
price
}
`
)
})
})
\ No newline at end of file
pages/composition-api/basic/define-options/define-options.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view class="page">
<text id="count" class='uni-common-mb'>count: {{ count }}</text>
<text id='double-count' class='uni-common-mb'>double count: {{ doubleCount}}</text>
<text id="total" class='uni-common-mb'>total: {{ total}}</text>
<button class="increment-btn" @click="increment">increment</button>
</view>
</template>
<script setup>
defineOptions({
data() {
return {
count: 0,
price: 10,
total: 0
}
},
computed: {
doubleCount() : number {
return this.count * 2
},
},
watch: {
count() {
this.total = this.price * this.count
},
},
methods: {
increment() {
this.count++
}
}
})
</script>
\ No newline at end of file
pages/composition-api/basic/define-props/array-literal.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<text class="bold uni-common-mb">array literal</text>
<text class="uni-common-mb" id="array-literal-str">str: {{ str }}</text>
<text class="uni-common-mb" id="array-literal-num">num: {{ num }}</text>
<text class="uni-common-mb" id="array-literal-bool">bool: {{ bool }}</text>
<text class="uni-common-mb" id="array-literal-arr">arr: {{ JSON.stringify(arr) }}</text>
<text class="uni-common-mb" id="array-literal-obj">obj: {{ JSON.stringify(obj) }}</text>
<text class="uni-common-mb" id="array-literal-fn">fn: {{ (fn as () => string)() }}</text>
</view>
</template>
<script setup>
defineProps(['str', 'num', 'bool', 'arr', 'obj', 'fn']);
</script>
pages/composition-api/basic/define-props/define-props.test.js
已删除
100644 → 0
浏览文件 @
90c33bc6
const
PAGE_PATH
=
'
/pages/composition-api/basic/define-props/define-props
'
describe
(
'
defineProps
'
,
()
=>
{
let
page
=
null
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
const
arrayLiteralStr
=
await
page
.
$
(
'
#array-literal-str
'
)
expect
(
await
arrayLiteralStr
.
text
()).
toBe
(
'
str: default str
'
)
const
arrayLiteralNum
=
await
page
.
$
(
'
#array-literal-num
'
)
expect
(
await
arrayLiteralNum
.
text
()).
toBe
(
'
num: 0
'
)
const
arrayLiteralBool
=
await
page
.
$
(
'
#array-literal-bool
'
)
expect
(
await
arrayLiteralBool
.
text
()).
toBe
(
'
bool: false
'
)
const
arrayLiteralArr
=
await
page
.
$
(
'
#array-literal-arr
'
)
expect
(
await
arrayLiteralArr
.
text
()).
toBe
(
'
arr: ["a","b","c"]
'
)
const
arrayLiteralObj
=
await
page
.
$
(
'
#array-literal-obj
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
await
arrayLiteralObj
.
text
()).
toBe
(
'
obj: {"arr":[1,2,3],"num":0,"str":"obj str"}
'
)
}
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
expect
(
await
arrayLiteralObj
.
text
()).
toBe
(
'
obj: {"str":"obj str","num":0,"arr":[1,2,3]}
'
)
}
const
arrayLiteralFn
=
await
page
.
$
(
'
#array-literal-fn
'
)
expect
(
await
arrayLiteralFn
.
text
()).
toBe
(
'
fn: fn res
'
)
const
objectLiteralStr
=
await
page
.
$
(
'
#object-literal-str
'
)
expect
(
await
objectLiteralStr
.
text
()).
toBe
(
'
str: default str
'
)
const
objectLiteralNum
=
await
page
.
$
(
'
#object-literal-num
'
)
expect
(
await
objectLiteralNum
.
text
()).
toBe
(
'
num: 0
'
)
const
objectLiteralBool
=
await
page
.
$
(
'
#object-literal-bool
'
)
expect
(
await
objectLiteralBool
.
text
()).
toBe
(
'
bool: false
'
)
const
objectLiteralArr
=
await
page
.
$
(
'
#object-literal-arr
'
)
expect
(
await
objectLiteralArr
.
text
()).
toBe
(
'
arr: ["a","b","c"]
'
)
const
objectLiteralObj
=
await
page
.
$
(
'
#object-literal-obj
'
)
expect
(
await
objectLiteralObj
.
text
()).
toBe
(
'
obj: {"a":1}
'
)
const
objectLiteralFn
=
await
page
.
$
(
'
#object-literal-fn
'
)
expect
(
await
objectLiteralFn
.
text
()).
toBe
(
'
fn: fn res
'
)
const
typeStr
=
await
page
.
$
(
'
#type-str
'
)
expect
(
await
typeStr
.
text
()).
toBe
(
'
str: default str
'
)
const
typeNum
=
await
page
.
$
(
'
#type-num
'
)
expect
(
await
typeNum
.
text
()).
toBe
(
'
num: 0
'
)
const
typeBool
=
await
page
.
$
(
'
#type-bool
'
)
expect
(
await
typeBool
.
text
()).
toBe
(
'
bool: false
'
)
const
typeArr
=
await
page
.
$
(
'
#type-arr
'
)
expect
(
await
typeArr
.
text
()).
toBe
(
'
arr: ["a","b","c"]
'
)
const
typeObj
=
await
page
.
$
(
'
#type-obj
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
await
typeObj
.
text
()).
toBe
(
'
obj: {"arr":[1,2,3],"num":0,"str":"obj str"}
'
)
}
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
expect
(
await
typeObj
.
text
()).
toBe
(
'
obj: {"str":"obj str","num":0,"arr":[1,2,3]}
'
)
}
const
typeFn
=
await
page
.
$
(
'
#type-fn
'
)
expect
(
await
typeFn
.
text
()).
toBe
(
'
fn: fn res
'
)
})
})
\ No newline at end of file
pages/composition-api/basic/define-props/define-props.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="page">
<ArrayLiteral :str="str" :num='num' :bool='bool' :arr='arr' :obj='obj' :fn='fn' />
<ObjectLiteral :str="str" :num='num' :bool='bool' :arr='arr' :fn='fn' />
<TypeProps :str="str" :num='num' :bool='bool' :arr='arr' :obj='obj' :fn='fn' />
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script setup>
import ArrayLiteral from './array-literal.uvue';
import ObjectLiteral from './object-literal.uvue';
import TypeProps from './type-props.uvue';
const str = ref('default str')
const num = ref(0)
const bool = ref(false)
const arr = reactive(['a', 'b', 'c'])
const obj = reactive({ str: 'obj str', num: 0, arr: [1, 2, 3] })
const fn = () : string => 'fn res'
</script>
\ No newline at end of file
pages/composition-api/basic/define-props/object-literal.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<text class="bold uni-common-mt uni-common-mb">object literal</text>
<text class="uni-common-mb" id="object-literal-str">str: {{ str }}</text>
<text class="uni-common-mb" id="object-literal-num">num: {{ num }}</text>
<text class="uni-common-mb" id="object-literal-bool">bool: {{ bool }}</text>
<text class="uni-common-mb" id="object-literal-arr">arr: {{ JSON.stringify(arr) }}</text>
<text class="uni-common-mb" id="object-literal-obj">obj: {{ JSON.stringify(obj) }}</text>
<text class="uni-common-mb" id="object-literal-fn">fn: {{ fn() }}</text>
</view>
</template>
<script setup>
defineProps({
str: String,
num: Number,
bool: {
type: Boolean,
default: true
},
arr: {
type: Array as PropType<string[]>,
default: () : string[] => [] as string[]
},
obj: {
type: Object as PropType<UTSJSONObject>,
default: () : UTSJSONObject => ({ a: 1 })
},
fn: {
type: Function as PropType<() => string>,
default: () : string => ''
}
})
</script>
\ No newline at end of file
pages/composition-api/basic/define-props/type-props.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<text class="bold uni-common-mt uni-common-mb">type props</text>
<text class="uni-common-mb" id="type-str">str: {{ str }}</text>
<text class="uni-common-mb" id="type-num">num: {{ num }}</text>
<text class="uni-common-mb" id="type-bool">bool: {{ bool }}</text>
<text class="uni-common-mb" id="type-arr">arr: {{ JSON.stringify(arr) }}</text>
<text class="uni-common-mb" id="type-obj">obj: {{ JSON.stringify(obj) }}</text>
<text id="type-fn">fn: {{ fn() }}</text>
</view>
</template>
<script setup>
defineProps<{
str : String,
num : Number,
bool : Boolean,
arr : PropType<string[]>,
obj : PropType<UTSJSONObject>,
fn : PropType<() => string>
}>()
</script>
\ No newline at end of file
pages/composition-api/basic/define-slots/Foo.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<slot name="header" :msg="msg"></slot>
<slot :num="num"></slot>
<slot name="footer" :arr="arr"></slot>
</view>
</template>
<script setup>
const msg = ref('foo msg')
const num = ref<number>(0)
const arr = ref<string[]>(['a', 'b', 'c'])
defineSlots<{
default(props : { msg : string }) : any,
header(props : { num : string }) : any,
footer(props : { arr : string[] }) : any
}>()
</script>
\ No newline at end of file
pages/composition-api/basic/define-slots/define-slots.test.js
已删除
100644 → 0
浏览文件 @
90c33bc6
const
PAGE_PATH
=
'
/pages/composition-api/basic/define-slots/define-slots
'
describe
(
'
defineSlots
'
,
()
=>
{
let
page
=
null
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
const
slotHeader
=
await
page
.
$
(
'
#slot-header
'
)
expect
(
await
slotHeader
.
text
()).
toBe
(
'
header slot msg: foo msg
'
)
const
slotContent
=
await
page
.
$
(
'
#slot-default
'
)
expect
(
await
slotContent
.
text
()).
toBe
(
'
default slot num: 0
'
)
const
slotFooter
=
await
page
.
$
(
'
#slot-footer
'
)
expect
(
await
slotFooter
.
text
()).
toBe
(
'
footer slot arr: ["a","b","c"]
'
)
})
})
\ No newline at end of file
pages/composition-api/basic/define-slots/define-slots.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view class="page">
<Foo>
<template #header="{msg}">
<text id="slot-header">header slot msg: {{msg}}</text>
</template>
<template #default="{num}">
<text id="slot-default" class="uni-common-mt">default slot num: {{num}}</text>
</template>
<template #footer="{arr}">
<text id="slot-footer" class="uni-common-mt">footer slot arr: {{JSON.stringify(arr)}}</text>
</template>
</Foo>
</view>
</template>
<script setup>
import Foo from './Foo.uvue'
</script>
\ No newline at end of file
pages/composition-api/basic/use-attrs/Foo.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view>
<text id="attrs-class">attrs.class: {{attrs['class']}}</text>
<text id="attrs-msg" class='uni-common-mt'>attrs.msg: {{attrs['msg']}}</text>
</view>
</template>
<script setup>
import { useAttrs } from 'vue'
const attrs = useAttrs()
</script>
<style>
.foo {
padding: 10px;
background-color: #09c;
}
</style>
\ No newline at end of file
pages/composition-api/basic/use-attrs/use-attrs.test.js
已删除
100644 → 0
浏览文件 @
90c33bc6
const
PAGE_PATH
=
'
/pages/composition-api/basic/use-attrs/use-attrs
'
describe
(
'
useAttrs
'
,
()
=>
{
let
page
=
null
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
const
attrsClass
=
await
page
.
$
(
'
#attrs-class
'
)
expect
(
await
attrsClass
.
text
()).
toBe
(
'
attrs.class: foo
'
)
const
attrsMsg
=
await
page
.
$
(
'
#attrs-msg
'
)
expect
(
await
attrsMsg
.
text
()).
toBe
(
'
attrs.msg: msg
'
)
})
})
\ No newline at end of file
pages/composition-api/basic/use-attrs/use-attrs.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view class="page">
<Foo class="foo" msg="msg">
</Foo>
</view>
</template>
<script setup>
import Foo from './Foo.uvue'
</script>
\ No newline at end of file
pages/composition-api/basic/use-slots/Foo.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<view class="page">
<slot name="header" :num="num"></slot>
<slot :msg="msg"></slot>
<slot name="footer" :arr="arr"></slot>
<text id="check-use-slots-res" class="uni-common-mt">check useSlots result: {{ checkUseSlotsRes }}</text>
<button class="check-use-slots-btn uni-common-mt" @click="checkUseSlots">
check useSlots
</button>
</view>
</template>
<script setup>
const num = ref<number>(0);
const msg = ref('default msg');
const arr = ref<string[]>(['a', 'b', 'c']);
const slots = defineSlots<{
default(props : { msg : string }) : any;
header(props : { num : number }) : any;
footer(props : { arr : string[] }) : any;
}>();
const slotsByUseSlots = useSlots();
const checkUseSlotsRes = ref(false);
const checkUseSlots = () => {
checkUseSlotsRes.value =
slots === slotsByUseSlots &&
slotsByUseSlots['default'] !== null &&
slotsByUseSlots['header'] !== null &&
slotsByUseSlots['footer'] !== null;
};
</script>
\ No newline at end of file
pages/composition-api/basic/use-slots/use-slots.test.js
已删除
100644 → 0
浏览文件 @
90c33bc6
const
PAGE_PATH
=
'
/pages/composition-api/basic/use-slots/use-slots
'
describe
(
'
useSlots
'
,
()
=>
{
let
page
=
null
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
basic
'
,
async
()
=>
{
const
slotHeader
=
await
page
.
$
(
'
#slot-header
'
)
expect
(
await
slotHeader
.
text
()).
toBe
(
'
header slot num: 0
'
)
const
slotContent
=
await
page
.
$
(
'
#slot-default
'
)
expect
(
await
slotContent
.
text
()).
toBe
(
'
default slot msg: default msg
'
)
const
slotFooter
=
await
page
.
$
(
'
#slot-footer
'
)
expect
(
await
slotFooter
.
text
()).
toBe
(
'
footer slot arr: ["a","b","c"]
'
)
const
checkUseSlotsRes
=
await
page
.
$
(
'
#check-use-slots-res
'
)
expect
(
await
checkUseSlotsRes
.
text
()).
toBe
(
'
check useSlots result: false
'
)
const
checkUseSlotsBtn
=
await
page
.
$
(
'
.check-use-slots-btn
'
)
await
checkUseSlotsBtn
.
tap
()
expect
(
await
checkUseSlotsRes
.
text
()).
toBe
(
'
check useSlots result: true
'
)
})
})
\ No newline at end of file
pages/composition-api/basic/use-slots/use-slots.uvue
已删除
100644 → 0
浏览文件 @
90c33bc6
<template>
<Foo>
<template #header="{num}">
<text id="slot-header">header slot num: {{num}}</text>
</template>
<template #default="{msg}">
<text id="slot-default" class="uni-common-mt">default slot msg: {{msg}}</text>
</template>
<template #footer="{arr}">
<text id="slot-footer" class="uni-common-mt">footer slot arr: {{JSON.stringify(arr)}}</text>
</template>
</Foo>
</template>
<script setup>
import Foo from './Foo.uvue'
</script>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录