Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
d4632f07
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看板
提交
d4632f07
编写于
4月 29, 2024
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 调整示例展示
上级
38c584d3
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
135 addition
and
116 deletion
+135
-116
pages.json
pages.json
+0
-2
pages/component-instance/mixins/components/Comp1.uvue
pages/component-instance/mixins/components/Comp1.uvue
+6
-4
pages/component-instance/mixins/components/Comp2.uvue
pages/component-instance/mixins/components/Comp2.uvue
+3
-5
pages/component-instance/mixins/mixins-web.uvue
pages/component-instance/mixins/mixins-web.uvue
+27
-5
pages/component-instance/props/array-literal-composition.uvue
...s/component-instance/props/array-literal-composition.uvue
+7
-1
pages/component-instance/props/array-literal-options.uvue
pages/component-instance/props/array-literal-options.uvue
+9
-1
pages/directive/v-bind/v-bind-options.uvue
pages/directive/v-bind/v-bind-options.uvue
+79
-82
pages/index/index.uvue
pages/index/index.uvue
+4
-16
未找到文件。
pages.json
浏览文件 @
d4632f07
...
...
@@ -201,7 +201,6 @@
"navigationBarTitleText"
:
"v-pre"
}
},
//
#ifdef
APP
{
"path"
:
"pages/directive/v-once/v-once-options"
,
"style"
:
{
...
...
@@ -226,7 +225,6 @@
"navigationBarTitleText"
:
"v-memo 组合式 API"
}
},
//
#endif
//
#ifdef
WEB
{
"path"
:
"pages/directive/v-text/v-text-options"
,
...
...
pages/component-instance/mixins/components/Comp1.uvue
浏览文件 @
d4632f07
<template>
<view class="mt-10" ref="mixin-comp-root">
<text class="bold">Comp1:</text>
<text class="mt-10"
>
inheritAttrs: false,
rootElementTitle should be null</text
<text class="bold">Comp1:
inheritAttrs: false
</text>
<text class="mt-10"
style="color:#ccc;"
>rootElementTitle should be null</text
>
<text class="mt-10 root-element-title-1">rootElementTitle: {{ rootElementTitle }}</text>
<!-- #ifdef APP -->
<text class="mt-10 bold">trigger emitter:</text>
<button class="mt-10 global-mixin-emit-1" @click="triggerEmitter('globalMixinEmit1')">
trigger globalMixinEmit1
...
...
@@ -29,6 +30,7 @@
trigger childMixinEmit
</button>
<MixinComp />
<!-- #endif -->
</view>
</template>
...
...
@@ -48,7 +50,7 @@ export default {
},
mounted(){
const rootElement = this.$refs['mixin-comp-root'] as UniElement
this.rootElementTitle =
rootElement.getAttribute('title'
)
this.rootElementTitle =
JSON.stringify(rootElement.getAttribute('title')
)
},
methods: {
triggerEmitter(emit: string){
...
...
pages/component-instance/mixins/components/Comp2.uvue
浏览文件 @
d4632f07
<template>
<view class="mt-10" ref="mixin-comp-root">
<text class="bold">Comp2:</text>
<text class="mt-10"
>inheritAttrs: true, rootElementTitle should not be null</text
>
<text class="bold">Comp2: inheritAttrs: true</text>
<text class="mt-10" style="color:#ccc;">rootElementTitle should not be null</text >
<text class="mt-10 root-element-title-2"
>rootElementTitle: {{ rootElementTitle }}</text
>
...
...
@@ -49,7 +47,7 @@ export default {
},
mounted(){
const rootElement = this.$refs['mixin-comp-root'] as UniElement
this.rootElementTitle =
rootElement.getAttribute('title'
)
this.rootElementTitle =
JSON.stringify(rootElement.getAttribute('title')
)
},
watch: {
globalMixinOnloadMsg1(newVal: string) {
...
...
pages/component-instance/mixins/mixins-web.uvue
浏览文件 @
d4632f07
...
...
@@ -7,6 +7,17 @@
<text id="mixin-data-msg" class="mb-10">mixinDataMsg: {{mixinDataMsg}}</text>
<text id="mixin-onload-msg" class="mb-10">mixinOnloadMsg: {{mixinOnloadMsg}}</text>
<text id="mixin-computed" class="mb-10">mixinComputed: {{mixinComputed}}</text>
<Comp1 title="title" @globalMixinEmit1="(arg: string) => handleMixinEmitter('globalMixinEmit1', arg)"
@globalChildMixinEmit1="(arg: string) => handleMixinEmitter('globalChildMixinEmit1', arg)"
@globalMixinEmit2="(arg: string) => handleMixinEmitter('globalMixinEmit2', arg)"
@globalChildMixinEmit2="(arg: string) => handleMixinEmitter('globalChildMixinEmit2', arg)"
@mixinEmit="(arg: string) => handleMixinEmitter('mixinEmit', arg)"
@childMixinEmit="(arg: string) => handleMixinEmitter('childMixinEmit', arg)" />
<text v-if="handleMixinEmitterMsg" class="mt-10 handle-mixin-emitter-msg">
handleMixinEmitterMsg: {{ handleMixinEmitterMsg }}
</text>
<Comp2 class='comp2' title="title" />
</view>
<!-- #ifdef APP -->
</scroll-view>
...
...
@@ -14,7 +25,13 @@
</template>
<script lang="uts">
import Comp1 from './components/Comp1.uvue'
import Comp2 from './components/Comp2.uvue'
export default {
components: {
Comp1,
Comp2,
},
mixins: [defineMixin({
props: {
mixinProp: {
...
...
@@ -24,12 +41,13 @@
},
data() {
return {
handleMixinEmitterMsg: '',
mixinDataMsg: '通过字面量定义非全局 mixin data',
mixinOnloadMsg: ''
}
},
computed: {
mixinComputed()
: string {
mixinComputed(): string {
const res = `通过字面量定义非全局 mixin computed, 更新后的 mixinOnloadMsg: ${this.mixinOnloadMsg}`
console.log(res)
return res
...
...
@@ -39,10 +57,14 @@
this.mixinOnloadMsg = 'mixin onLoad msg in onLoad'
},
methods: {
mixinMethod()
: string {
mixinMethod(): string {
const res = '通过字面量定义非全局 mixin method'
console.log(res)
return res
},
handleMixinEmitter(emit: string, arg: string) {
this.handleMixinEmitterMsg = `触发 ${emit}, 参数为 ${arg}`
console.log(this.handleMixinEmitterMsg)
}
},
})]
...
...
pages/component-instance/props/array-literal-composition.uvue
浏览文件 @
d4632f07
...
...
@@ -25,5 +25,11 @@
</template>
<script setup lang="uts">
defineProps(['str', 'num', 'bool', 'obj', 'arr'])
const props = defineProps(['str', 'num', 'bool', 'obj', 'arr'])
console.log('props.str: ',props.str);
console.log('props.num: ',props.num);
console.log('props.obj: ',props.obj);
console.log('props.bool: ',props.bool);
console.log('props.arr: ',props.arr);
</script>
pages/component-instance/props/array-literal-options.uvue
浏览文件 @
d4632f07
...
...
@@ -27,5 +27,13 @@
<script lang="uts">
export default {
props: ['str', 'num', 'bool', 'obj', 'arr'],
mounted() {
console.log('this.$props is Map', this.$props, this.$props instanceof Map);
console.log('this.$props.str: ',this.$props['str']);
console.log('this.$props.num: ',this.$props['num']);
console.log('this.$props.bool: ',this.$props['bool']);
console.log('this.$props.arr: ',this.$props['arr']);
console.log('this.$props.obj: ',this.$props['obj']);
}
};
</script>
pages/directive/v-bind/v-bind-options.uvue
浏览文件 @
d4632f07
<template>
<view class="page">
<!-- v-bind attribute -->
<button id="disabled-btn" class="mb-10" :disabled="true">
:disabled true
</button>
<button id="v-bind-disabled-btn" class="mb-10" v-bind:disabled="false">
v-bind:disabled false
</button>
<button id="disabled-btn" class="mb-10" :disabled="true">:disabled true</button>
<button id="v-bind-disabled-btn" class="mb-10" v-bind:disabled="false">v-bind:disabled false</button>
<!-- v-bind style -->
<view class="flex justify-between flex-row mb-10">
...
...
@@ -22,7 +18,7 @@
</view>
<!-- v-bind props -->
<Foo :title
="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<Foo :title
:num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<!-- v-bind in style -->
<!-- #ifdef WEB -->
...
...
@@ -32,51 +28,52 @@
</template>
<script lang="uts">
import Foo from './Foo-options.uvue'
import Foo from './Foo-options.uvue'
type FooPropsObj = {
name : string
}
type FooProps = {
title : string
num : number
obj : FooPropsObj
}
type DataInfo = {
fontSize : string
backgroundColor : string
border : string
fooProps : FooProps
vBindClassBackgroundColor : string,
}
type FooPropsObj = {
name: string
}
type FooProps = {
title: string
num: number
obj: FooPropsObj
}
type DataInfo = {
fontSize: string
backgroundColor: string
border: string
fooProps: FooProps
vBindClassBackgroundColor: string
}
export default {
export default {
components: { Foo },
data() {
return {
title: 'foo title',
dataInfo: {
fontSize: '20px',
backgroundColor: 'background-color: green',
border: 'border: 2px solid red',
fooProps: {
title: 'foo title',
title: '',
num: 1,
obj: {
name: 'foo obj name',
name: 'foo obj name'
}
},
vBindClassBackgroundColor: 'red',
vBindClassBackgroundColor: 'red'
} as DataInfo
}
},
}
}
</script>
<style>
/* #ifdef WEB */
.v-bind-css {
/* #ifdef WEB */
.v-bind-css {
background-color: v-bind(dataInfo.vBindClassBackgroundColor);
height: 20px;
}
/* #endif */
}
/* #endif */
</style>
pages/index/index.uvue
浏览文件 @
d4632f07
...
...
@@ -725,18 +725,12 @@ export default {
{
id: 'v-once-options',
name: 'v-once 选项式 API',
url: 'v-once-options',
// #ifdef WEB
enable: false
// #endif
url: 'v-once-options'
},
{
id: 'v-once-composition',
name: 'v-once 组合式 API',
url: 'v-once-composition',
// #ifdef WEB
enable: false
// #endif
url: 'v-once-composition'
},
]
},
...
...
@@ -747,18 +741,12 @@ export default {
{
id: 'v-memo-options',
name: 'v-memo 选项式 API',
url: 'v-memo-options',
// #ifdef WEB
enable: false
// #endif
url: 'v-memo-options'
},
{
id: 'v-memo-composition',
name: 'v-memo 组合式 API',
url: 'v-memo-composition',
// #ifdef WEB
enable: false
// #endif
url: 'v-memo-composition'
},
]
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录