项目自述
管理系统 To B
Vue 原型方法

Vue 原型方法

注意 以下方法都是挂载到 Vue中原型上的方法 可直接通过this.的方式进行调用使用

  1. $getConfig 获取配置
  2. $getDataKeys 获取前端自定义字典
  3. $shtEmitter 发布订阅模式

$shtEmitter 发布订阅功能

发布订阅功能 用于消息通知

  1. on 订阅
  2. emit 发布
<script >
export default {
  created() {
    // 订阅
    // on 接受两个参数   1、订阅的事件名称   2、订阅执行方法
    this.$shtEmitter.on('purchase-warehouse', (...r) => {
       // 发布动作执行后 触发此方法执行
       console.log(r); // ['11', 2, 'xx']
    });
  },
  methods: {
    // 某种操作触发
    handleClick() {
      // 发布
      // emit 第一个参数必传.   第二个之后的参数  会传到 订阅执行方法上
      this.$shtEmitter.emit('test', '11', 2, 'xx');
    },
  },
}
 
</script>