250x250
Notice
Recent Posts
Recent Comments
«   2025/02   »
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
Tags
more
Archives
Today
Total
관리 메뉴

진스

간단한 event Bus 등록 및 사용예 본문

Vue

간단한 event Bus 등록 및 사용예

입방정 2021. 4. 24. 23:08
728x90

1.src 폴더 - utils폴더 - bus.js 생성

 

 

- bus.js  간단한 생성

import Vue from "vue";

export default new Vue();

 

 

- 보낼 파일내 ex) mixins.js 

.then(() => {

        console.log("fetchlset");

        bus.$emit("end:spinner");

      })

 

 

 

-받을 파일내  ex) App.vue

<template>

       ....

  <spinner :loading="loadingStatus"></spinner>

       ....

</template>

 

  created() {

    bus.$on("start:spinner", this.startSpinner);

    bus.$on("end:spinner", this.endSpinner);

  },

  methods: {

    startSpinner() {

      this.loadingStatus = true;

    },

    endSpinner() {

      this.loadingStatus = false;

    },

728x90
Comments