vue

vue动态组件,传递参数

动态组件,传递参数

Posted by Sunfy on 2021-09-14
Words 266 and Reading Time 1 Minutes
Viewed Times
Viewed Times
Visitors In Total

vue 动态组件,传递参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<template>
<div class="acea-row row-middle">
<el-avatar
icon="el-icon-s-operation"
size="small"
style="color: #1890ff; background: #e6f7ff; font-size: 13px"
/>
<span class="ivu-pl-8">选择日期:</span>
<template style="width: 110px">
<el-date-picker
v-model="query"
placeholder="选择日期">
</el-date-picker>
</template>
</div>
<!-- 上面是参数,下面是自定义组件 -->
<DeviceOeeDay
:type="type"
:date="query"/>
</template>
<script>
export default {
data() {
return {
query: formatDate(new Date(), 'yyyy-MM-dd'),
type: "day"
// query: ""
}
},
methods: {
changeType(value) {
this.type = value;
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<template>
<div :class="className" :style="{height:height,width:width}"/>
</template>
<script>
export default {
props: {
date: {//日期
type: Date,
default: formatDate(new Date(), 'yyyy-MM-dd')
},
type: {//类别
type: String,
default: "day"
}
},
// 监控数据变化,数据变化后会执行对应的数据监控方法
watch: {
date(newDate) { //更新标识观测
this.date = formatDate(newDate, 'yyyy-MM-dd')
this.initChart()
},
type(newType) {
this.type = newType
this.initChart()
}
}
}
</script>


Copyright 2021 sunfy.top ALL Rights Reserved

...

...

00:00
00:00