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',