4

我正在使用 ng2-dragula 并在 2 个表中进行数据绑定。当一个 td 被拖放到另一个表时,它会抛出 Uncaught TypeError: Cannot read property 'splice' of undefined。并且无法删除该元素。需要有关如何解决此问题的帮助。

下面是html部分

    <table class="table">
        <thead class="text-primary">
            <tr>
                <th>Task ID</th>
                <th>Ref #</th>
                <th>Customer Name</th>
                <th>Doc Type</th>
                <th>Date</th>
            </tr>
        </thead>
        <tbody [dragula]='"team-bag"' [dragulaModel]="tasks">
            <tr *ngFor="let t of tasks">
                <td>{{t.id}}</td>
                <td>{{t.refNbr}}</td>
                <td>{{t.custName}}</td>
                <td>{{t.docType}}</td>
                <td>{{t.receiveDate}}</td>
            </tr>
        </tbody>
    </table>
    
        <table class="table">
        <thead class="text-primary">
            <tr>
                <th>Task ID</th>
                <th>Ref #</th>
                <th>Customer Name</th>
                <th>Doc Type</th>
                <th>Date</th>
            </tr>
        </thead>
        <tbody [dragula]='"team-bag"' [dragulaModel]="agentATasks">
            <tr *ngFor="let t of agentATasks">
                <td>{{t.id}}</td>
                <td>{{t.refNbr}}</td>
                <td>{{t.custName}}</td>
                <td>{{t.docType}}</td>
                <td>{{t.receiveDate}}</td>
            </tr>
        </tbody>
    </table>

tasks 和 agentATasks 都在 component.ts 中定义和填充。

以下是 Chrome 控制台中的错误。Subscriber.ts:241 Uncaught TypeError: Cannot read property 'splice' of undefined at Object.eval ( http://localhost:3002/node_modules/ng2-dragula/components/dragula.provider.js:94:28 ) 在发射器 ( http://localhost:3002/node_modules/contra/emitter.js:47:72)在 Object.eval 的 Array.forEach (本机)(http://localhost:3002/node_modules/contra/emitter.js:46: 10 ) 在 Object.thing.emit ( http://localhost:3002/node_modules/contra/emitter.js:38:48 ) 在 drop ( http://localhost:3002/node_modules/dragula/dragula.js:261: 13 ) 在 HTMLHtmlElement.release ( http://localhost:3002/node_modules/dragula/dragula.js:245:7) 在 ZoneDelegate.invokeTask ( http://localhost:3002/node_modules/zone.js/dist/zone.js:265:35 ) 在 Object.onInvokeTask ( http://localhost:3002/node_modules/@angular/core/ bundles/core.umd.js:5967:41 ) 在 ZoneDelegate.invokeTask ( http://localhost:3002/node_modules/zone.js/dist/zone.js:264:40 )

4

0 回答 0