xe3에서 vue 사용하기
유저 이미지
분쟁제로
- 2018.06.25
- 조회수 627
- 댓글수 2
밑에 답변 감사드립니다.
vue를 써보려하는데
laravel & vue 로 검색하면 많은 글이 나오긴 하지만 거의 모두 npm이용해서 설치하는 방식인데
xe3에서는 코어와 얽히?는 관계로 아직 안되는 것으로 이해하였습니다.
그러면 그냥 스크립트로 소스를 직접 넣어 쓰는 방법을 써야할텐데
혹시나........ vue 쓰실 수 있는분 계시면 도움 주시면 매우 황망하겠습니다.
기본적으로 아래 코드는 잘 작동합니다. 그런데 다른 배포된 컴포넌트를 이용하기가 어려워서 질문드립니다.
==========잘 작동하는 기본 코드===========
<script src="https://unpkg.com/vue"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id="app_SK">
@{{ message }}
<span v-text="message"></span>
<input v-model="message">
</div>
<script>
var app_test = new Vue({
el: '#app_SK',
data :{
message : '지금 시각은 ' + new Date()
}
})
</script>
위처럼 그냥 페이지에 넣어서 사용하려 하는데
이미 배포된 유명한 플러그인(컴포넌트)를 쓰려하니까
import 부분을 어떻게 해야하는지 모르겠습니다.
============ 해결하고자 하는 코드 ===========
<script src="https://unpkg.com/vue"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<template>
<div :style="{ 'display': 'flex', 'justifyContent': 'stretch', 'marginTop': '50px', 'marginRight': '50px' }">
<div :style="{'marginLeft': '50px', 'flex': '1'}">
<Container :group-name="'1'" :get-child-payload="getChildPayload1" @drop="onDrop('items1', $event)">
<Draggable v-for="item in items1" :key="item.id">
<div class="draggable-item">
@{{item.data}}
</div>
</Draggable>
</Container>
</div>
.......
</template>
<script>
import { Container, Draggable } from "vue-smooth-dnd";
<<<<<<<< npm install vue-smooth-dnd 로 하면 이렇게 하면 되는데, 소스 직접다운시에는 이부분을 어떻게 해야할지요.
import { applyDrag, generateItems } from "./utils"; <<<<<<<< 이부분
export default {
name: "Groups",
components: { Container, Draggable },
data: function() {
return {
items1: generateItems(15, i => ({
id: "1" + i,
data: `Draggable 1 - ${i}`
})),
items2: generateItems(15, i => ({
id: "2" + i,
data: `Draggable 2 - ${i}`
})),
items3: generateItems(15, i => ({
id: "3" + i,
data: `Draggable 3 - ${i}`
})),
items4: generateItems(15, i => ({
id: "4" + i,
data: `Draggable 3 - ${i}`
}))
};
},
methods: {
onDrop: function(collection, dropResult) {
this[collection] = applyDrag(this[collection], dropResult);
},
getChildPayload1: function(index) {
return this.items1[index];
},
getChildPayload2: function(index) {
return this.items2[index];
},
getChildPayload3: function(index) {
return this.items3[index];
},
getChildPayload4: function(index) {
return this.items4[index];
}
}
};
</script>
이리저리 해보고 해결되면 답글올리겠습니다.
감사합니다.
0개 댓글