我正在研究Angular2和NG2-Dragula
我也在使用Bootstrap 3。
这是html和构造函数代码:
HTML:
<div class="container">
<div class="row">
<div class="col-md-4" [dragula]='"sortable"'>
<div class="box">1 Moving items between containers works as usual</div>
</div>
<div class="col-md-4" [dragula]='"sortable"'>
<div class="box">2 Moving items between containers works as usual</div>
</div>
<div class="col-md-4" [dragula]='"sortable"'>
<div class="box">3 Moving items between containers works as usual</div>
</div>
</div>
</div>
构造
constructor(private dragulaService: DragulaService) {
dragulaService.setOptions('sortable', {
revertOnSpill: false
});
}
目前它只是排序/移动的一面,但是当我需要时,它可以向任何方向移动。
这是不是因为构造函数代码错误或html而发生?我该如何解决这个问题?
答案 0 :(得分:3)
只需将html更改为:
<div class="container">
<div class="row" [dragula]='"sortable"'>
<div class="col-md-4">
<div class="box">1 Moving items between containers works as usual</div>
</div>
<div class="col-md-4">
<div class="box">2 Moving items between containers works as usual</div>
</div>
<div class="col-md-4">
<div class="box">3 Moving items between containers works as usual</div>
</div>
</div>
</div>
将[dragula] ='“sortable”'添加到div class =“row”