Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
d4632f07
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
349
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 @@
...
@@ -201,7 +201,6 @@
"navigationBarTitleText"
:
"v-pre"
"navigationBarTitleText"
:
"v-pre"
}
}
},
},
//
#ifdef
APP
{
{
"path"
:
"pages/directive/v-once/v-once-options"
,
"path"
:
"pages/directive/v-once/v-once-options"
,
"style"
:
{
"style"
:
{
...
@@ -226,7 +225,6 @@
...
@@ -226,7 +225,6 @@
"navigationBarTitleText"
:
"v-memo 组合式 API"
"navigationBarTitleText"
:
"v-memo 组合式 API"
}
}
},
},
//
#endif
//
#ifdef
WEB
//
#ifdef
WEB
{
{
"path"
:
"pages/directive/v-text/v-text-options"
,
"path"
:
"pages/directive/v-text/v-text-options"
,
...
...
pages/component-instance/mixins/components/Comp1.uvue
浏览文件 @
d4632f07
<template>
<template>
<view class="mt-10" ref="mixin-comp-root">
<view class="mt-10" ref="mixin-comp-root">
<text class="bold">Comp1:</text>
<text class="bold">Comp1:
inheritAttrs: false
</text>
<text class="mt-10"
<text class="mt-10"
style="color:#ccc;"
>
inheritAttrs: false,
rootElementTitle should be null</text
>rootElementTitle should be null</text
>
>
<text class="mt-10 root-element-title-1">rootElementTitle: {{ rootElementTitle }}</text>
<text class="mt-10 root-element-title-1">rootElementTitle: {{ rootElementTitle }}</text>
<!-- #ifdef APP -->
<text class="mt-10 bold">trigger emitter:</text>
<text class="mt-10 bold">trigger emitter:</text>
<button class="mt-10 global-mixin-emit-1" @click="triggerEmitter('globalMixinEmit1')">
<button class="mt-10 global-mixin-emit-1" @click="triggerEmitter('globalMixinEmit1')">
trigger globalMixinEmit1
trigger globalMixinEmit1
...
@@ -29,6 +30,7 @@
...
@@ -29,6 +30,7 @@
trigger childMixinEmit
trigger childMixinEmit
</button>
</button>
<MixinComp />
<MixinComp />
<!-- #endif -->
</view>
</view>
</template>
</template>
...
@@ -48,7 +50,7 @@ export default {
...
@@ -48,7 +50,7 @@ export default {
},
},
mounted(){
mounted(){
const rootElement = this.$refs['mixin-comp-root'] as UniElement
const rootElement = this.$refs['mixin-comp-root'] as UniElement
this.rootElementTitle =
rootElement.getAttribute('title'
)
this.rootElementTitle =
JSON.stringify(rootElement.getAttribute('title')
)
},
},
methods: {
methods: {
triggerEmitter(emit: string){
triggerEmitter(emit: string){
...
...
pages/component-instance/mixins/components/Comp2.uvue
浏览文件 @
d4632f07
<template>
<template>
<view class="mt-10" ref="mixin-comp-root">
<view class="mt-10" ref="mixin-comp-root">
<text class="bold">Comp2:</text>
<text class="bold">Comp2: inheritAttrs: true</text>
<text class="mt-10"
<text class="mt-10" style="color:#ccc;">rootElementTitle should not be null</text >
>inheritAttrs: true, rootElementTitle should not be null</text
>
<text class="mt-10 root-element-title-2"
<text class="mt-10 root-element-title-2"
>rootElementTitle: {{ rootElementTitle }}</text
>rootElementTitle: {{ rootElementTitle }}</text
>
>
...
@@ -49,7 +47,7 @@ export default {
...
@@ -49,7 +47,7 @@ export default {
},
},
mounted(){
mounted(){
const rootElement = this.$refs['mixin-comp-root'] as UniElement
const rootElement = this.$refs['mixin-comp-root'] as UniElement
this.rootElementTitle =
rootElement.getAttribute('title'
)
this.rootElementTitle =
JSON.stringify(rootElement.getAttribute('title')
)
},
},
watch: {
watch: {
globalMixinOnloadMsg1(newVal: string) {
globalMixinOnloadMsg1(newVal: string) {
...
...
pages/component-instance/mixins/mixins-web.uvue
浏览文件 @
d4632f07
<template>
<template>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<scroll-view style="flex: 1">
<!-- #endif -->
<!-- #endif -->
<view class="page">
<view class="page">
<text id="mixin-prop" class="mb-10">mixinProp: {{mixinProp}}</text>
<text id="mixin-prop" class="mb-10">mixinProp: {{mixinProp}}</text>
<text id="mixin-data-msg" class="mb-10">mixinDataMsg: {{mixinDataMsg}}</text>
<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-onload-msg" class="mb-10">mixinOnloadMsg: {{mixinOnloadMsg}}</text>
<text id="mixin-computed" class="mb-10">mixinComputed: {{mixinComputed}}</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>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
<!-- #endif -->
<!-- #endif -->
</template>
</template>
<script lang="uts">
<script lang="uts">
import Comp1 from './components/Comp1.uvue'
import Comp2 from './components/Comp2.uvue'
export default {
export default {
components: {
Comp1,
Comp2,
},
mixins: [defineMixin({
mixins: [defineMixin({
props: {
props: {
mixinProp: {
mixinProp: {
...
@@ -24,12 +41,13 @@
...
@@ -24,12 +41,13 @@
},
},
data() {
data() {
return {
return {
handleMixinEmitterMsg: '',
mixinDataMsg: '通过字面量定义非全局 mixin data',
mixinDataMsg: '通过字面量定义非全局 mixin data',
mixinOnloadMsg: ''
mixinOnloadMsg: ''
}
}
},
},
computed: {
computed: {
mixinComputed()
: string {
mixinComputed(): string {
const res = `通过字面量定义非全局 mixin computed, 更新后的 mixinOnloadMsg: ${this.mixinOnloadMsg}`
const res = `通过字面量定义非全局 mixin computed, 更新后的 mixinOnloadMsg: ${this.mixinOnloadMsg}`
console.log(res)
console.log(res)
return res
return res
...
@@ -39,12 +57,16 @@
...
@@ -39,12 +57,16 @@
this.mixinOnloadMsg = 'mixin onLoad msg in onLoad'
this.mixinOnloadMsg = 'mixin onLoad msg in onLoad'
},
},
methods: {
methods: {
mixinMethod()
: string {
mixinMethod(): string {
const res = '通过字面量定义非全局 mixin method'
const res = '通过字面量定义非全局 mixin method'
console.log(res)
console.log(res)
return res
return res
},
handleMixinEmitter(emit: string, arg: string) {
this.handleMixinEmitterMsg = `触发 ${emit}, 参数为 ${arg}`
console.log(this.handleMixinEmitterMsg)
}
}
},
},
})]
})]
}
}
</script>
</script>
\ No newline at end of file
pages/component-instance/props/array-literal-composition.uvue
浏览文件 @
d4632f07
...
@@ -25,5 +25,11 @@
...
@@ -25,5 +25,11 @@
</template>
</template>
<script setup lang="uts">
<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>
</script>
pages/component-instance/props/array-literal-options.uvue
浏览文件 @
d4632f07
<template>
<template>
<view>
<view>
<text class="mb-10 bold">array literal</text>
<text class="mb-10 bold">array literal</text>
<view class="mb-10 flex justify-between flex-row">
<view class="mb-10 flex justify-between flex-row">
<text>str: </text>
<text>str: </text>
...
@@ -27,5 +27,13 @@
...
@@ -27,5 +27,13 @@
<script lang="uts">
<script lang="uts">
export default {
export default {
props: ['str', 'num', 'bool', 'obj', 'arr'],
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>
</script>
pages/directive/v-bind/v-bind-options.uvue
浏览文件 @
d4632f07
<template>
<template>
<view class="page">
<view class="page">
<!-- v-bind attribute -->
<!-- v-bind attribute -->
<button id="disabled-btn" class="mb-10" :disabled="true">
<button id="disabled-btn" class="mb-10" :disabled="true">:disabled true</button>
:disabled true
<button id="v-bind-disabled-btn" class="mb-10" v-bind:disabled="false">v-bind:disabled false</button>
</button>
<button id="v-bind-disabled-btn" class="mb-10" v-bind:disabled="false">
<!-- v-bind style -->
v-bind:disabled false
<view class="flex justify-between flex-row mb-10">
</button>
<text>bind object style fontSize:</text>
<text id="bind-object-style" :style="{ fontSize: dataInfo.fontSize }">
<!-- v-bind style -->
{{ dataInfo.fontSize }}
<view class="flex justify-between flex-row mb-10">
</text>
<text>bind object style fontSize:</text>
</view>
<text id="bind-object-style" :style="{ fontSize: dataInfo.fontSize }">
<view id="bind-array-style" class="mb-10 p-10" :style="[dataInfo.backgroundColor, dataInfo.border]">
{{ dataInfo.fontSize }}
<view>bind arr style</view>
</text>
<view class="my-10">{{ dataInfo.backgroundColor }}</view>
</view>
<view>{{ dataInfo.border }}</view>
<view id="bind-array-style" class="mb-10 p-10" :style="[dataInfo.backgroundColor, dataInfo.border]">
</view>
<view>bind arr style</view>
<view class="my-10">{{ dataInfo.backgroundColor }}</view>
<!-- v-bind props -->
<view>{{ dataInfo.border }}</view>
<Foo :title :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
</view>
<!-- v-bind in style -->
<!-- v-bind props -->
<!-- #ifdef WEB -->
<Foo :title="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<view class="mb-10 v-bind-css"></view>
<!-- #endif -->
<!-- v-bind in style -->
</view>
<!-- #ifdef WEB -->
</template>
<view class="mb-10 v-bind-css"></view>
<!-- #endif -->
<script lang="uts">
</view>
import Foo from './Foo-options.uvue'
</template>
type FooPropsObj = {
<script lang="uts">
name: string
import Foo from './Foo-options.uvue'
}
type FooProps = {
type FooPropsObj = {
title: string
name : string
num: number
}
obj: FooPropsObj
type FooProps = {
}
title : string
type DataInfo = {
num : number
fontSize: string
obj : FooPropsObj
backgroundColor: string
}
border: string
type DataInfo = {
fooProps: FooProps
fontSize : string
vBindClassBackgroundColor: string
backgroundColor : string
}
border : string
fooProps : FooProps
export default {
vBindClassBackgroundColor : string,
components: { Foo },
}
data() {
return {
export default {
title: 'foo title',
components: { Foo },
dataInfo: {
data() {
fontSize: '20px',
return {
backgroundColor: 'background-color: green',
dataInfo: {
border: 'border: 2px solid red',
fontSize: '20px',
fooProps: {
backgroundColor: 'background-color: green',
title: '',
border: 'border: 2px solid red',
num: 1,
fooProps: {
obj: {
title: 'foo title',
name: 'foo obj name'
num: 1,
}
obj: {
},
name: 'foo obj name',
vBindClassBackgroundColor: 'red'
}
} as DataInfo
},
}
vBindClassBackgroundColor: 'red',
}
} as DataInfo
}
}
</script>
},
}
<style>
</script>
/* #ifdef WEB */
.v-bind-css {
<style>
background-color: v-bind(dataInfo.vBindClassBackgroundColor);
/* #ifdef WEB */
height: 20px;
.v-bind-css {
}
background-color: v-bind(dataInfo.vBindClassBackgroundColor);
/* #endif */
height: 20px;
</style>
}
/* #endif */
</style>
\ No newline at end of file
pages/index/index.uvue
浏览文件 @
d4632f07
...
@@ -725,18 +725,12 @@ export default {
...
@@ -725,18 +725,12 @@ export default {
{
{
id: 'v-once-options',
id: 'v-once-options',
name: 'v-once 选项式 API',
name: 'v-once 选项式 API',
url: 'v-once-options',
url: 'v-once-options'
// #ifdef WEB
enable: false
// #endif
},
},
{
{
id: 'v-once-composition',
id: 'v-once-composition',
name: 'v-once 组合式 API',
name: 'v-once 组合式 API',
url: 'v-once-composition',
url: 'v-once-composition'
// #ifdef WEB
enable: false
// #endif
},
},
]
]
},
},
...
@@ -747,18 +741,12 @@ export default {
...
@@ -747,18 +741,12 @@ export default {
{
{
id: 'v-memo-options',
id: 'v-memo-options',
name: 'v-memo 选项式 API',
name: 'v-memo 选项式 API',
url: 'v-memo-options',
url: 'v-memo-options'
// #ifdef WEB
enable: false
// #endif
},
},
{
{
id: 'v-memo-composition',
id: 'v-memo-composition',
name: 'v-memo 组合式 API',
name: 'v-memo 组合式 API',
url: 'v-memo-composition',
url: 'v-memo-composition'
// #ifdef WEB
enable: false
// #endif
},
},
]
]
},
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录