This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm i --save-dev expose-loader | |
npm i --save jquery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var EventBus = Vue(); | |
Object.defineProperties(Vue.prototype, { | |
$eventBus: { | |
get: function () { | |
return EventBus; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var EventBus = new Vue(); | |
var SenderApp = new Vue({ | |
el: '#sender-app', | |
data() { | |
return { | |
text: '', | |
receiveText: '' | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="sender-app"> | |
<input v-model="text"> | |
<button @click="sender">sender</button> | |
<div v-if="receiveText">#sender-app: I sent a message a {{ receiveText }}</div> | |
</div> | |
<div id="receiver-app"> | |
<div v-if="text">#receiver-app: {{ text }}</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 이벤트 구독 | |
EventBus.$on('message', function(text) { | |
console.log(text); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 이벤트 발행 | |
EventBus.$emit('message', 'hello world'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 이벤트버스 생성 | |
var EventBus = new Vue() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
created: function() { | |
// ... | |
this.$nextTick(function() { | |
var dom = document.getElementById('item-0'); | |
dom.style.backgroundColor = 'red'; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 오류 예제 --> | |
<div id="app"> | |
<div v-for="item in list"> | |
<div v-bind:id="bindId(item)">{{item}}</div> <!-- 2 --> | |
</div> | |
</div> | |
<script> | |
new Vue({ | |
el: '#app', |