Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
9368da8a
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看板
提交
9368da8a
编写于
12月 12, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(mixins): 优化变量声明
上级
a7c49e06
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
51 deletion
+51
-51
pages/composition/mixins/mixins.uts
pages/composition/mixins/mixins.uts
+51
-51
未找到文件。
pages/composition/mixins/mixins.uts
浏览文件 @
9368da8a
...
@@ -3,121 +3,121 @@ import ChildMixinComp1 from './components/ChildMixinComp1.uvue'
...
@@ -3,121 +3,121 @@ import ChildMixinComp1 from './components/ChildMixinComp1.uvue'
import MixinCompForMixin from './components/MixinCompForMixin.uvue'
import MixinCompForMixin from './components/MixinCompForMixin.uvue'
import MixinCompForChildMixin from './components/MixinCompForChildMixin.uvue'
import MixinCompForChildMixin from './components/MixinCompForChildMixin.uvue'
export const pageMixin = defineMixin({
const childMixin = defineMixin({
mixins: [childMixin],
components: { ChildMixinComp1, MixinComp: MixinCompForChildMixin },
components: { MixinComp1, MixinComp: MixinCompForMixin },
props: {
props: {
m
ixinProp1: {
childM
ixinProp1: {
type: String,
type: String,
default: '通过 defineMixin 定义非全局 mixin props'
default: '通过 defineMixin 定义非全局
child
mixin props'
},
},
namesakeMixinProp: {
namesake
Child
MixinProp: {
type: String,
type: String,
default: '通过 defineMixin 定义非全局同名 mixin props'
default: '通过 defineMixin 定义非全局同名
child
mixin props'
}
}
},
},
data() {
data() {
return {
return {
mixinDataMsg1: '通过 defineMixin 定义非全局
mixin data',
childMixinDataMsg1: '通过 defineMixin 定义非全局 child
mixin data',
namesakeMixinDataMsg: '通过 defineMixin 定义非全局同名 mixin data',
namesake
Child
MixinDataMsg: '通过 defineMixin 定义非全局同名 mixin data',
m
ixinOnloadMsg1: '',
childM
ixinOnloadMsg1: '',
m
ixinOnloadTime1: 0,
childM
ixinOnloadTime1: 0,
m
ixinWatchMsg1: ''
childM
ixinWatchMsg1: ''
}
}
},
},
computed: {
computed: {
m
ixinComputed1(): string {
childM
ixinComputed1(): string {
const res = `通过 defineMixin 定义非全局
mixin computed, 更新后的 mixinOnloadMsg1: ${this.m
ixinOnloadMsg1}`
const res = `通过 defineMixin 定义非全局
child mixin computed, 更新后的 childMixinOnloadMsg1: ${this.childM
ixinOnloadMsg1}`
console.log(res)
console.log(res)
return res
return res
},
},
namesakeMixinComputed(): string {
namesake
Child
MixinComputed(): string {
const res = '通过 defineMixin 定义非全局同名
mixin
computed'
const res = '通过 defineMixin 定义非全局同名
child
computed'
console.log(res)
console.log(res)
return res
return res
}
}
},
},
watch: {
watch: {
globalMixinOnloadMsg1(newVal: string) {
globalMixinOnloadMsg1(newVal: string) {
this.
mixinWatchMsg1 = `通过 defineMixin 定义非全局
mixin watch, 更新后的 globalMixinOnloadMsg1: ${newVal}`
this.
childMixinWatchMsg1 = `通过 defineMixin 定义非全局 child
mixin watch, 更新后的 globalMixinOnloadMsg1: ${newVal}`
console.log(this.
m
ixinWatchMsg1)
console.log(this.
childM
ixinWatchMsg1)
},
},
},
},
onLoad() {
onLoad() {
this.
m
ixinOnloadTime1 = Date.now()
this.
childM
ixinOnloadTime1 = Date.now()
const res = '通过 defineMixin 定义非全局 mixin onLoad'
const res = '通过 defineMixin 定义非全局
child
mixin onLoad'
console.log(res)
console.log(res)
this.
m
ixinOnloadMsg1 = res
this.
childM
ixinOnloadMsg1 = res
},
},
methods: {
methods: {
m
ixinMethod1(): string {
childM
ixinMethod1(): string {
const res = '通过 defineMixin 定义非全局 mixin method'
const res = '通过 defineMixin 定义非全局
child
mixin method'
console.log(res)
console.log(res)
return res
return res
},
},
namesakeMixinMethod(): string {
namesake
Child
MixinMethod(): string {
const res = '通过 defineMixin 定义非全局同名 mixin method'
const res = '通过 defineMixin 定义非全局同名
child
mixin method'
console.log(res)
console.log(res)
return res
return res
}
}
,
}
}
})
})
const childMixin = defineMixin({
export const pageMixin = defineMixin({
components: { ChildMixinComp1, MixinComp: MixinCompForChildMixin },
mixins: [childMixin],
components: { MixinComp1, MixinComp: MixinCompForMixin },
props: {
props: {
childM
ixinProp1: {
m
ixinProp1: {
type: String,
type: String,
default: '通过 defineMixin 定义非全局
child
mixin props'
default: '通过 defineMixin 定义非全局 mixin props'
},
},
namesake
Child
MixinProp: {
namesakeMixinProp: {
type: String,
type: String,
default: '通过 defineMixin 定义非全局同名
child
mixin props'
default: '通过 defineMixin 定义非全局同名 mixin props'
}
}
},
},
data() {
data() {
return {
return {
childMixinDataMsg1: '通过 defineMixin 定义非全局 child
mixin data',
mixinDataMsg1: '通过 defineMixin 定义非全局
mixin data',
namesake
Child
MixinDataMsg: '通过 defineMixin 定义非全局同名 mixin data',
namesakeMixinDataMsg: '通过 defineMixin 定义非全局同名 mixin data',
childM
ixinOnloadMsg1: '',
m
ixinOnloadMsg1: '',
childM
ixinOnloadTime1: 0,
m
ixinOnloadTime1: 0,
childM
ixinWatchMsg1: ''
m
ixinWatchMsg1: ''
}
}
},
},
computed: {
computed: {
childM
ixinComputed1(): string {
m
ixinComputed1(): string {
const res = `通过 defineMixin 定义非全局
child mixin computed, 更新后的 childMixinOnloadMsg1: ${this.childM
ixinOnloadMsg1}`
const res = `通过 defineMixin 定义非全局
mixin computed, 更新后的 mixinOnloadMsg1: ${this.m
ixinOnloadMsg1}`
console.log(res)
console.log(res)
return res
return res
},
},
namesake
Child
MixinComputed(): string {
namesakeMixinComputed(): string {
const res = '通过 defineMixin 定义非全局同名
child
computed'
const res = '通过 defineMixin 定义非全局同名
mixin
computed'
console.log(res)
console.log(res)
return res
return res
}
}
},
},
watch: {
watch: {
globalMixinOnloadMsg1(newVal: string) {
globalMixinOnloadMsg1(newVal: string) {
this.
childMixinWatchMsg1 = `通过 defineMixin 定义非全局 child
mixin watch, 更新后的 globalMixinOnloadMsg1: ${newVal}`
this.
mixinWatchMsg1 = `通过 defineMixin 定义非全局
mixin watch, 更新后的 globalMixinOnloadMsg1: ${newVal}`
console.log(this.
childM
ixinWatchMsg1)
console.log(this.
m
ixinWatchMsg1)
},
},
},
},
onLoad() {
onLoad() {
this.
childM
ixinOnloadTime1 = Date.now()
this.
m
ixinOnloadTime1 = Date.now()
const res = '通过 defineMixin 定义非全局
child
mixin onLoad'
const res = '通过 defineMixin 定义非全局 mixin onLoad'
console.log(res)
console.log(res)
this.
childM
ixinOnloadMsg1 = res
this.
m
ixinOnloadMsg1 = res
},
},
methods: {
methods: {
childM
ixinMethod1(): string {
m
ixinMethod1(): string {
const res = '通过 defineMixin 定义非全局
child
mixin method'
const res = '通过 defineMixin 定义非全局 mixin method'
console.log(res)
console.log(res)
return res
return res
},
},
namesake
Child
MixinMethod(): string {
namesakeMixinMethod(): string {
const res = '通过 defineMixin 定义非全局同名
child
mixin method'
const res = '通过 defineMixin 定义非全局同名 mixin method'
console.log(res)
console.log(res)
return res
return res
}
,
}
}
}
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录