2017-05-15 11 views
0

나는 Vue.js에 비교적 새로운 해요 지금은 내 Laravel 응용 프로그램으로이 플러그인 vue-chat-scroll를 설치할하지만,이 오류가 발생합니다 :laravel의 VUE 가져 오기 플러그인 [VUE-채팅 스크롤]

[Vue warn]: Failed to resolve directive: chat-scroll

(found in [ChatLog])

npm install --save vue-chat-scroll을 성공적으로 실행했습니다.
package.json는 플러그인에 대한 enty 있습니다 추가 정보에 설명 된대로 나는이 개 라인을 추가 bootstrap.js에서

"dependencies": {  
    "laravel-echo": "^1.3.0", 
    "pusher-js": "^4.1.0", 
    "vue-chat-scroll": "^1.1.1" 
} 

. 내 ChatLog.vue에서

window.Vue = require('vue'); 

import VueChatScroll from 'vue-chat-scroll' 
Vue.use(VueChatScroll); 


window.axios = require('axios'); 

window.axios.defaults.headers.common = { 
    'X-CSRF-TOKEN': window.Laravel.csrfToken, 
    'X-Requested-With': 'XMLHttpRequest' 
}; 

은 내가 v-chat-scroll 지시어를 추가했다.

<template lang="html"> 
<div class="chat-log" v-chat-scroll> 
    <chat-message v-for="message in messages" :message="message"></chat-message> 
</div> 
</template> 

<script > 
export default{ 
    props: ['messages'] 

} 
</script> 

무엇이 누락 되었습니까?

+0

당신은 다시 컴파일나요 bootstrap.js에서 제거 할 수 있습니다 최적화 할 것이다 자산을'bootstrap.js'에서 참조한 후에? 또한'import ('문서에서 ES5 방식) 대신'require ('vue-chat-scroll')'시도해 볼 수도 있습니다. – Alex

답변

1

단일 파일 구성 요소를 사용하는 경우 구성 요소 자체 내에 요구 사항을 정의해야합니다.

이 시도 :

<script > 
import Vue from 'vue' 
import VueChatScroll from 'vue-chat-scroll' 
Vue.use(VueChatScroll) 

export default{ 
    props: ['messages'] 
} 
</script> 

을 그것은 짜증나지만 다행히도 웹팩는 듀얼이 필요하거나,이 경우 당신이 그것을 필요로하는 유일한 장소 당신이