Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
740a387d
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
376
Star
3
Fork
8
代码
文件
提交
分支
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看板
提交
740a387d
编写于
7月 24, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(v-bind): 修复类型错误
上级
a0cd00b0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
177 addition
and
187 deletion
+177
-187
pages/directive/v-bind/Foo-composition.uvue
pages/directive/v-bind/Foo-composition.uvue
+4
-6
pages/directive/v-bind/Foo-options.uvue
pages/directive/v-bind/Foo-options.uvue
+10
-12
pages/directive/v-bind/type.uts
pages/directive/v-bind/type.uts
+8
-0
pages/directive/v-bind/v-bind-composition.uvue
pages/directive/v-bind/v-bind-composition.uvue
+78
-88
pages/directive/v-bind/v-bind-options.uvue
pages/directive/v-bind/v-bind-options.uvue
+77
-81
未找到文件。
pages/directive/v-bind/Foo-composition.uvue
浏览文件 @
740a387d
...
...
@@ -10,15 +10,13 @@
</view>
<view class="flex justify-between flex-row mb-10">
<text>props obj['name']:</text>
<text id="foo-props-obj-name">{{ obj
['name']
}}</text>
<text id="foo-props-obj-name">{{ obj
.name
}}</text>
</view>
</view>
</template>
<script setup lang="uts">
export type FooPropsObj = {
name : string
}
import { FooPropsObj } from './type.uts'
defineProps({
title: {
...
...
@@ -34,8 +32,8 @@
default: false
},
obj: {
type:
FooPropsObj
,
required: true
type:
Object as PropType<FooPropsObj>
,
default: {name: 'default name'} as FooPropsObj
}
})
</script>
\ No newline at end of file
pages/directive/v-bind/Foo-options.uvue
浏览文件 @
740a387d
...
...
@@ -10,16 +10,14 @@
</view>
<view class="flex justify-between flex-row mb-10">
<text>props obj['name']:</text>
<text id='foo-props-obj-name'>{{ obj
['name']
}}</text>
<text id='foo-props-obj-name'>{{ obj
.name
}}</text>
</view>
</view>
</template>
<script lang="uts">
export type FooPropsObj = {
name : string
}
<script lang="uts">
import { FooPropsObj } from './type.uts'
export default {
props: {
title: {
...
...
@@ -29,14 +27,14 @@
num: {
type: Number,
default: 0
},
checked: {
type: Boolean,
default: false
},
checked: {
type: Boolean,
default: false
},
obj: {
type:
FooPropsObj
,
required: true
type:
Object as PropType<FooPropsObj>
,
default: {name: 'default name'} as FooPropsObj
}
}
}
...
...
pages/directive/v-bind/type.uts
0 → 100644
浏览文件 @
740a387d
export type FooPropsObj = {
name : string
}
export type FooProps = {
title : string
num : number
obj : FooPropsObj
}
\ No newline at end of file
pages/directive/v-bind/v-bind-composition.uvue
浏览文件 @
740a387d
<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>
<!-- v-bind style -->
<view class="flex justify-between flex-row mb-10">
<text>bind object style fontSize:</text>
<text id="bind-object-style" :style="{ fontSize: dataInfo.fontSize }">
{{ dataInfo.fontSize }}
</text>
</view>
<view
id="bind-array-style"
class="mb-10 p-10"
:style="[dataInfo.backgroundColor, dataInfo.border]">
<view>bind arr style</view>
<view class="my-10">{{ dataInfo.backgroundColor }}</view>
<view>{{ dataInfo.border }}</view>
</view>
<!-- v-bind props -->
<Foo
:title="dataInfo.fooProps.title"
:num="dataInfo.fooProps.num"
:obj="dataInfo.fooProps.obj" />
<!-- v-bind props -->
<Foo checked />
<!-- v-bind in style -->
<!-- #ifdef WEB -->
<view class="mb-10 v-bind-css"></view>
<!-- #endif -->
</view>
</template>
<script setup lang="uts">
import Foo from './Foo-composition.uvue'
import {type FooPropsObj} from './Foo-composition.uvue'
type FooProps = {
title : string
num : number
obj : FooPropsObj
}
type DataInfo = {
fontSize : string
backgroundColor : string
border : string
fooProps : FooProps
vBindClassBackgroundColor : string,
vBindClassRpxHeight : string,
}
const dataInfo = reactive({
fontSize: '20px',
backgroundColor: 'background-color: green',
border: 'border: 2px solid red',
fooProps: {
title: 'foo title',
num: 1,
obj: {
name: 'foo obj name',
} as FooPropsObj
},
vBindClassBackgroundColor: 'red',
vBindClassRpxHeight: '300rpx'
} as DataInfo)
defineExpose({
dataInfo
})
</script>
<style>
/* #ifdef WEB */
.v-bind-css {
background-color: v-bind(dataInfo.vBindClassBackgroundColor);
height: v-bind(dataInfo.vBindClassRpxHeight);
}
/* #endif */
</style>
<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>
<!-- v-bind style -->
<view class="flex justify-between flex-row mb-10">
<text>bind object style fontSize:</text>
<text id="bind-object-style" :style="{ fontSize: dataInfo.fontSize }">
{{ dataInfo.fontSize }}
</text>
</view>
<view id="bind-array-style" class="mb-10 p-10" :style="[dataInfo.backgroundColor, dataInfo.border]">
<view>bind arr style</view>
<view class="my-10">{{ dataInfo.backgroundColor }}</view>
<view>{{ dataInfo.border }}</view>
</view>
<!-- v-bind props -->
<Foo :title="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<!-- v-bind props -->
<Foo checked />
<!-- v-bind in style -->
<!-- #ifdef WEB -->
<view class="mb-10 v-bind-css"></view>
<!-- #endif -->
</view>
</template>
<script setup lang="uts">
import Foo from './Foo-composition.uvue'
import { FooProps, FooPropsObj } from './type.uts'
type DataInfo = {
fontSize : string
backgroundColor : string
border : string
fooProps : FooProps
vBindClassBackgroundColor : string,
vBindClassRpxHeight : string,
}
const dataInfo = reactive({
fontSize: '20px',
backgroundColor: 'background-color: green',
border: 'border: 2px solid red',
fooProps: {
title: 'foo title',
num: 1,
obj: {
name: 'foo obj name',
} as FooPropsObj
},
vBindClassBackgroundColor: 'red',
vBindClassRpxHeight: '300rpx'
} as DataInfo)
defineExpose({
dataInfo
})
</script>
<style>
/* #ifdef WEB */
.v-bind-css {
background-color: v-bind(dataInfo.vBindClassBackgroundColor);
height: v-bind(dataInfo.vBindClassRpxHeight);
}
/* #endif */
</style>
\ No newline at end of file
pages/directive/v-bind/v-bind-options.uvue
浏览文件 @
740a387d
<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>
<!-- v-bind style -->
<view class="flex justify-between flex-row mb-10">
<text>bind object style fontSize:</text>
<text id="bind-object-style" :style="{ fontSize: dataInfo.fontSize }">
{{ dataInfo.fontSize }}
</text>
</view>
<view id="bind-array-style" class="mb-10 p-10" :style="[dataInfo.backgroundColor, dataInfo.border]">
<view>bind arr style</view>
<view class="my-10">{{ dataInfo.backgroundColor }}</view>
<view>{{ dataInfo.border }}</view>
</view>
<!-- v-bind props -->
<Foo :title="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<!-- v-bind props -->
<Foo checked />
<!-- v-bind in style -->
<!-- #ifdef WEB -->
<view class="mb-10 v-bind-css"></view>
<!-- #endif -->
</view>
</template>
<script lang="uts">
import Foo from './Foo-options.uvue'
import {type FooPropsObj} from './Foo-options.uvue'
type FooProps = {
title: string
num: number
obj: FooPropsObj
}
type DataInfo = {
fontSize: string
backgroundColor: string
border: string
fooProps: FooProps
vBindClassBackgroundColor: string
vBindClassRpxHeight: string
}
export default {
components: { Foo },
data() {
return {
dataInfo: {
fontSize: '20px',
backgroundColor: 'background-color: green',
border: 'border: 2px solid red',
fooProps: {
title: 'foo title',
num: 1,
obj: {
name: 'foo obj name'
} as FooPropsObj
},
vBindClassBackgroundColor: 'red',
vBindClassRpxHeight: '300rpx'
} as DataInfo
}
}
}
</script>
<style>
/* #ifdef WEB */
.v-bind-css {
background-color: v-bind(dataInfo.vBindClassBackgroundColor);
height: v-bind(dataInfo.vBindClassRpxHeight);
}
/* #endif */
</style>
<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>
<!-- v-bind style -->
<view class="flex justify-between flex-row mb-10">
<text>bind object style fontSize:</text>
<text id="bind-object-style" :style="{ fontSize: dataInfo.fontSize }">
{{ dataInfo.fontSize }}
</text>
</view>
<view id="bind-array-style" class="mb-10 p-10" :style="[dataInfo.backgroundColor, dataInfo.border]">
<view>bind arr style</view>
<view class="my-10">{{ dataInfo.backgroundColor }}</view>
<view>{{ dataInfo.border }}</view>
</view>
<!-- v-bind props -->
<Foo :title="dataInfo.fooProps.title" :num="dataInfo.fooProps.num" :obj="dataInfo.fooProps.obj" />
<!-- v-bind props -->
<Foo checked />
<!-- v-bind in style -->
<!-- #ifdef WEB -->
<view class="mb-10 v-bind-css"></view>
<!-- #endif -->
</view>
</template>
<script lang="uts">
import Foo from './Foo-options.uvue'
import { FooProps, FooPropsObj } from './type.uts'
type DataInfo = {
fontSize : string
backgroundColor : string
border : string
fooProps : FooProps
vBindClassBackgroundColor : string
vBindClassRpxHeight : string
}
export default {
components: { Foo },
data() {
return {
dataInfo: {
fontSize: '20px',
backgroundColor: 'background-color: green',
border: 'border: 2px solid red',
fooProps: {
title: 'foo title',
num: 1,
obj: {
name: 'foo obj name'
} as FooPropsObj
},
vBindClassBackgroundColor: 'red',
vBindClassRpxHeight: '300rpx'
} as DataInfo
}
}
}
</script>
<style>
/* #ifdef WEB */
.v-bind-css {
background-color: v-bind(dataInfo.vBindClassBackgroundColor);
height: v-bind(dataInfo.vBindClassRpxHeight);
}
/* #endif */
</style>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录