我正在尝试使用 jQuery Nestable 库,我必须将 data-id 和 data-weight 设置为我的列表元素。这是所需的列表架构:
<div class="dd" id="nestable">
<ol class="dd-list">
<li class="dd-item" data-id="10" data-weight="1">
<div class="dd-handle">Item 1</div>
</li>
<li class="dd-item" data-id="29" data-weight="2">
<div class="dd-handle">Item 2</div>
</li>
<li class="dd-item" data-id="58" data-weight="3">
<div class="dd-handle">Item 11</div>
</li>
</ol>
</div>
但是,每次我尝试为元素分配属性时,都会出现以下错误:
Can't bind to 'weight' since it isn't a known property of 'li'.
这是我的 nestable.directive.ts:
@Directive({ selector: '[uiNestable]' })
export class NestableDirective {
constructor(el: ElementRef) {
$(el.nativeElement).nestable({
group: 1
});
}
}
任何帮助表示赞赏。