Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
9368da8a
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看板
提交
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'
import MixinCompForMixin from './components/MixinCompForMixin.uvue'
import MixinCompForChildMixin from './components/MixinCompForChildMixin.uvue'
export const pageMixin = defineMixin({
mixins: [childMixin],
components: { MixinComp1, MixinComp: MixinCompForMixin },
const childMixin = defineMixin({
components: { ChildMixinComp1, MixinComp: MixinCompForChildMixin },
props: {
m
ixinProp1: {
childM
ixinProp1: {
type: String,
default: '通过 defineMixin 定义非全局 mixin props'
default: '通过 defineMixin 定义非全局
child
mixin props'
},
namesakeMixinProp: {
namesake
Child
MixinProp: {
type: String,
default: '通过 defineMixin 定义非全局同名 mixin props'
default: '通过 defineMixin 定义非全局同名
child
mixin props'
}
},
data() {
return {
mixinDataMsg1: '通过 defineMixin 定义非全局
mixin data',
namesakeMixinDataMsg: '通过 defineMixin 定义非全局同名 mixin data',
m
ixinOnloadMsg1: '',
m
ixinOnloadTime1: 0,
m
ixinWatchMsg1: ''
childMixinDataMsg1: '通过 defineMixin 定义非全局 child
mixin data',
namesake
Child
MixinDataMsg: '通过 defineMixin 定义非全局同名 mixin data',
childM
ixinOnloadMsg1: '',
childM
ixinOnloadTime1: 0,
childM
ixinWatchMsg1: ''
}
},
computed: {
m
ixinComputed1(): string {
const res = `通过 defineMixin 定义非全局
mixin computed, 更新后的 mixinOnloadMsg1: ${this.m
ixinOnloadMsg1}`
childM
ixinComputed1(): string {
const res = `通过 defineMixin 定义非全局
child mixin computed, 更新后的 childMixinOnloadMsg1: ${this.childM
ixinOnloadMsg1}`
console.log(res)
return res
},
namesakeMixinComputed(): string {
const res = '通过 defineMixin 定义非全局同名
mixin
computed'
namesake
Child
MixinComputed(): string {
const res = '通过 defineMixin 定义非全局同名
child
computed'
console.log(res)
return res
}
},
watch: {
globalMixinOnloadMsg1(newVal: string) {
this.
mixinWatchMsg1 = `通过 defineMixin 定义非全局
mixin watch, 更新后的 globalMixinOnloadMsg1: ${newVal}`
console.log(this.
m
ixinWatchMsg1)
this.
childMixinWatchMsg1 = `通过 defineMixin 定义非全局 child
mixin watch, 更新后的 globalMixinOnloadMsg1: ${newVal}`
console.log(this.
childM
ixinWatchMsg1)
},
},
onLoad() {
this.
m
ixinOnloadTime1 = Date.now()
const res = '通过 defineMixin 定义非全局 mixin onLoad'
this.
childM
ixinOnloadTime1 = Date.now()
const res = '通过 defineMixin 定义非全局
child
mixin onLoad'
console.log(res)
this.
m
ixinOnloadMsg1 = res
this.
childM
ixinOnloadMsg1 = res
},
methods: {
m
ixinMethod1(): string {
const res = '通过 defineMixin 定义非全局 mixin method'
childM
ixinMethod1(): string {
const res = '通过 defineMixin 定义非全局
child
mixin method'
console.log(res)
return res
},
namesakeMixinMethod(): string {
const res = '通过 defineMixin 定义非全局同名 mixin method'
namesake
Child
MixinMethod(): string {
const res = '通过 defineMixin 定义非全局同名
child
mixin method'
console.log(res)
return res
}
}
,
}
})
const childMixin = defineMixin({
components: { ChildMixinComp1, MixinComp: MixinCompForChildMixin },
export const pageMixin = defineMixin({
mixins: [childMixin],
components: { MixinComp1, MixinComp: MixinCompForMixin },
props: {
childM
ixinProp1: {
m
ixinProp1: {
type: String,
default: '通过 defineMixin 定义非全局
child
mixin props'
default: '通过 defineMixin 定义非全局 mixin props'
},
namesake
Child
MixinProp: {
namesakeMixinProp: {
type: String,
default: '通过 defineMixin 定义非全局同名
child
mixin props'
default: '通过 defineMixin 定义非全局同名 mixin props'
}
},
data() {
return {
childMixinDataMsg1: '通过 defineMixin 定义非全局 child
mixin data',
namesake
Child
MixinDataMsg: '通过 defineMixin 定义非全局同名 mixin data',
childM
ixinOnloadMsg1: '',
childM
ixinOnloadTime1: 0,
childM
ixinWatchMsg1: ''
mixinDataMsg1: '通过 defineMixin 定义非全局
mixin data',
namesakeMixinDataMsg: '通过 defineMixin 定义非全局同名 mixin data',
m
ixinOnloadMsg1: '',
m
ixinOnloadTime1: 0,
m
ixinWatchMsg1: ''
}
},
computed: {
childM
ixinComputed1(): string {
const res = `通过 defineMixin 定义非全局
child mixin computed, 更新后的 childMixinOnloadMsg1: ${this.childM
ixinOnloadMsg1}`
m
ixinComputed1(): string {
const res = `通过 defineMixin 定义非全局
mixin computed, 更新后的 mixinOnloadMsg1: ${this.m
ixinOnloadMsg1}`
console.log(res)
return res
},
namesake
Child
MixinComputed(): string {
const res = '通过 defineMixin 定义非全局同名
child
computed'
namesakeMixinComputed(): string {
const res = '通过 defineMixin 定义非全局同名
mixin
computed'
console.log(res)
return res
}
},
watch: {
globalMixinOnloadMsg1(newVal: string) {
this.
childMixinWatchMsg1 = `通过 defineMixin 定义非全局 child
mixin watch, 更新后的 globalMixinOnloadMsg1: ${newVal}`
console.log(this.
childM
ixinWatchMsg1)
this.
mixinWatchMsg1 = `通过 defineMixin 定义非全局
mixin watch, 更新后的 globalMixinOnloadMsg1: ${newVal}`
console.log(this.
m
ixinWatchMsg1)
},
},
onLoad() {
this.
childM
ixinOnloadTime1 = Date.now()
const res = '通过 defineMixin 定义非全局
child
mixin onLoad'
this.
m
ixinOnloadTime1 = Date.now()
const res = '通过 defineMixin 定义非全局 mixin onLoad'
console.log(res)
this.
childM
ixinOnloadMsg1 = res
this.
m
ixinOnloadMsg1 = res
},
methods: {
childM
ixinMethod1(): string {
const res = '通过 defineMixin 定义非全局
child
mixin method'
m
ixinMethod1(): string {
const res = '通过 defineMixin 定义非全局 mixin method'
console.log(res)
return res
},
namesake
Child
MixinMethod(): string {
const res = '通过 defineMixin 定义非全局同名
child
mixin method'
namesakeMixinMethod(): string {
const res = '通过 defineMixin 定义非全局同名 mixin method'
console.log(res)
return res
}
,
}
}
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录