我是TypeScript的新手。我有这样的界面:
<div class="slick_demo_2">
<?php
foreach ($boardPins as $boardPin)
{
?>
<div class="file-box">
<div class="file">
<a href="">
<span class="corner"></span>
<div class="icon">
<i class="fa fa-folder " style="color: #1ab394"></i>
</div>
<div class="file-name text-center">
<span class="badge badge-primary">
Text
</span>
</div>
</a>
</div>
</div>
<?php
}
?>
</div>
然后我尝试这样做:
$('.slick_demo_2').slick({
infinite: true,
slidesToShow: 3,
slidesToScroll: 1,
centerMode: false
});
尽管我已经使用默认值export interface Stop {
sequenceNumber?: number | null;
}
来对 stops.sort((stopA: Stop, stopB: Stop) => {
const { sequenceNumber: seqA = 0 } = stopA;
const { sequenceNumber: seqB = 0 } = stopB;
return seqA - seqB;
});
和Object is possibly 'null'
进行了seqA
的构造,但它仍然抱怨seqB
。
为什么这样做,人们通常如何克服呢?
更令人困惑的是,如果我这样写的话:
0
打字稿不抱怨。两种方法都不能有效地完成同一件事吗?