采用的是子传父,父传子的方式
1,子传父:
通过this.$emit(‘func’,this.groupData)
func:是定义的一个方法名,
groupData:是要传的东西
get_api_service_api_group(
{
user_service_id: self.user_service_id
}
).then(res => {
console.log(res)
this.groupData = res.groups
this.KaTeX parse error: Expected 'EOF', got '}' at position 55: …s.init() }̲).catch(err => …route.params.group_id,
group_name: this.
r
o
u
t
e
.
p
a
r
a
m
s
.
g
r
o
u
p
n
a
m
e
,
G
r
o
u
p
D
a
t
a
:
[
]
/
/
s
e
r
v
i
c
e
i
d
:
t
h
i
s
.
route.params.group_name, GroupData:[] // service_id: this.
route.params.groupname,GroupData:[]//serviceid:this.route.params.service_id
}
},
created() {
this.group_id = this.
r
o
u
t
e
.
p
a
r
a
m
s
.
g
r
o
u
p
i
d
t
h
i
s
.
g
r
o
u
p
n
a
m
e
=
t
h
i
s
.
route.params.group_id this.group_name = this.
route.params.groupidthis.groupname=this.route.params.group_name
console.log(this.group_id, this.group_name, ‘父组件的状态’)
// this.service_id = this.$route.params.service_id
},
methods: {
getMsgFormSon(data){
console.log(data, ‘接受值’)
this.GroupData = data
}
}
}
3,弟弟组件接受父的值
props:{
GroupData:{
type:[Array],
default:""
}
},
然后直接在template中使用