§ Fox3.0前端框架-消息机制
标签(空格分隔): Fox
§ 1. 消息接收
消息接收函数,在Fox Flow中定义,如下
export default {
name: "example_money-item",
//数据
data:function(){
return {
}
},
//方法
methods:{
},
//Fox流程
fox_flow() {
return {
/**
* 消息
* @param type
* @param data
*/
onMessage(type, data){
},
}
}
}
onMessage的参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| type | String | 消息类型 |
| data | Object | 消息内容 |
§ 2. 消息发送
消息发送,可通过路由和vue name作为目标
###2.1 路由
let location = {
route:{path:"/frame"}
}
let type = "openPage"
let data = {type:'check'}
this.fox_send(location, type, data)
如上函数所示,定义一个route对象,设置route path或name,定义消息内容data和消息类型,调用fox_send函数发送消息
###2.2 Vue名称
2.2.1 什么是Vue名称
export default {
name: "example_money-item",
//数据
data:function(){
return {
}
},
//方法
methods:{
},
//Fox流程
fox_flow() {
return {
/**
* 消息
* @param type
* @param data
*/
onMessage(type, data){
},
}
}
}
上述对象的 name: "example_money-item",就是Vue的名称,如果需要往其发送消息,代码如下
let type = "openPage"
let data = {type:'check'}
this.fox_send(“example_money-item”, type, data)
如果有同名的Vue对象,那么两个Vue中的fox_flow的onMessage都会收到该消息