Skip to content

Instantly share code, notes, and snippets.

View devjin0617's full-sized avatar
๐Ÿ’ป
์ €๋Š” ๊ฐœ๋ฐœ์„ ํ•ฉ๋‹ˆ๋‹ค

cheongjin kim (๊น€์ฒญ์ง„) devjin0617

๐Ÿ’ป
์ €๋Š” ๊ฐœ๋ฐœ์„ ํ•ฉ๋‹ˆ๋‹ค
View GitHub Profile
npm i --save-dev expose-loader
npm i --save jquery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
(function() {
var EventBus = Vue();
Object.defineProperties(Vue.prototype, {
$eventBus: {
get: function () {
return EventBus;
}
}
var EventBus = new Vue();
var SenderApp = new Vue({
el: '#sender-app',
data() {
return {
text: '',
receiveText: ''
}
},
<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>
// ์ด๋ฒคํŠธ ๊ตฌ๋…
EventBus.$on('message', function(text) {
console.log(text);
});
// ์ด๋ฒคํŠธ ๋ฐœํ–‰
EventBus.$emit('message', 'hello world');
// ์ด๋ฒคํŠธ๋ฒ„์Šค ์ƒ์„ฑ
var EventBus = new Vue()
created: function() {
// ...
this.$nextTick(function() {
var dom = document.getElementById('item-0');
dom.style.backgroundColor = 'red';
});
}
<!-- ์˜ค๋ฅ˜ ์˜ˆ์ œ -->
<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',