home2 ๊ฒŒ์‹œํŒ Vue ๊ฒŒ์‹œํŒ emitter ์˜ค๋ฅ˜

emitter ์˜ค๋ฅ˜

  • ์ด ์ฃผ์ œ์—๋Š” 2๊ฐœ ๋‹ต๋ณ€, 2๋ช… ์ฐธ์—ฌ๊ฐ€ ์žˆ์œผ๋ฉฐ ์กฐ์—ฐ๊ด€๊ฐ€ 5 ๋…„, 4 ์›” ์ „์— ์ „์— ๋งˆ์ง€๋ง‰์œผ๋กœ ์—…๋ฐ์ดํŠธํ–ˆ์Šต๋‹ˆ๋‹ค.
3 ๊ธ€ ๋ณด์ž„ - 1 ์—์„œ 3 ๊นŒ์ง€ (์ด 3 ์ค‘์—์„œ)
  • ๊ธ€์“ด์ด
    ๊ธ€
  • #9003

    ์กฐ์—ฐ๊ด€
    ์ฐธ๊ฐ€์ž

    main.js

    import { createApp } from "vue";
    import App from "./App.vue";
    import mitt from "mitt";
    let emitter = mitt;
    let app = createApp(App);
    app.config.globalProperties.emitter = emitter;
    app.mount("#app");

     

    FilterBox.vue

    <div @click="fire" :class= "'${filter} filter-item'" :style="'background-image : url(${url})'">
     

    <script>
    export default {
        name: 'filterbox',
        props: {
            url: String,
            filter: String,
        },
        methods: {
            fire(){
                this.emitter.emit('๋ฐ•์Šคํด๋ฆญํ•จ',this.filter)
                console.log('fire')
            }
        }
    }
    </script>

    ๋ผ๊ณ  ์ž‘์„ฑํ•˜์˜€๋Š”๋ฐ console.log์—๋Š”

    Uncaught TypeError: this.emitter.emit is not a function ๋ผ๊ณ ๋งŒ ๋‚˜์˜ต๋‹ˆ๋‹ค..์–ด๋””๊ฐ€ ๋ฌธ์ œ ์ผ๊นŒ์š”? 

     

     

    #9012

    codingapple
    ํ‚ค ๋งˆ์Šคํ„ฐ

    let emitter = mitt() ๊ฐ™์€๋ฐ์š” 

    #9015

    ์กฐ์—ฐ๊ด€
    ์ฐธ๊ฐ€์ž

    ๋น ๋ฅธ ๋‹ต๋ณ€ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.. ํ™•์ธํ•ด๋ณผ๊ฒŒ์š”!

3 ๊ธ€ ๋ณด์ž„ - 1 ์—์„œ 3 ๊นŒ์ง€ (์ด 3 ์ค‘์—์„œ)
  • ๋‹ต๋ณ€์€ ๋กœ๊ทธ์ธ ํ›„ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

About

ํ˜„์žฌ ์›” 700๋ช… ์‹ ๊ทœ์ˆ˜๊ฐ•์ค‘์ž…๋‹ˆ๋‹ค.

  (09:00~20:00) ๋น ๋ฅธ ์ƒ๋‹ด์€ ์นดํ†ก ํ”Œ๋Ÿฌ์Šค์นœ๊ตฌ ์ฝ”๋”ฉ์• ํ”Œ (๋งํฌ)
  admin@codingapple.com
  ์ด์šฉ์•ฝ๊ด€, ๊ฐœ์ธ์ •๋ณด์ฒ˜๋ฆฌ๋ฐฉ์นจ
โ“’ Codingapple, ๊ฐ•์˜ ์˜ˆ์ œ, ์˜์ƒ ๋ณต์ œ ๊ธˆ์ง€
top

ยฉ Codingapple, All rights reserved. ์Šˆํผ๋กœ์ผ“ ์—๋“€์ผ€์ด์…˜ / ์„œ์šธํŠน๋ณ„์‹œ ๊ฐ•๋™๊ตฌ ๊ณ ๋•๋กœ 19๊ธธ 30 / ์‚ฌ์—…์ž๋“ฑ๋ก๋ฒˆํ˜ธ: 212-26-14752 ์˜จ๋ผ์ธ ๊ต์œกํ•™์›์—… / ํ†ต์‹ ํŒ๋งค์—…์‹ ๊ณ : ์ œ 2017-์„œ์šธ๊ฐ•๋™-0002 ํ˜ธ / ๊ฐœ์ธ์ •๋ณด๊ด€๋ฆฌ์ž: ๋ฐ•์ข…ํ  / ๋Œ€ํ‘œ์ž๋ช…: ๋ฐ•ํ•ด์œค