mirror of
https://gitee.com/coder-xiaomo/algorithm-visualization
synced 2025-09-07 13:21:39 +08:00
修复数组为空Bug弹窗
This commit is contained in:
@@ -59,13 +59,14 @@ class ArrayVi extends ViBase {
|
|||||||
if (!sortClassInfo['available'])
|
if (!sortClassInfo['available'])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
let that = this
|
||||||
let ctrlBtn = document.createElement("button")
|
let ctrlBtn = document.createElement("button")
|
||||||
ctrlBtn.innerHTML = sortClassInfo['name']
|
ctrlBtn.innerHTML = sortClassInfo['name']
|
||||||
ctrlBtn.onclick = function () {
|
ctrlBtn.onclick = function () {
|
||||||
// 点击排序算法按钮
|
// 点击排序算法按钮
|
||||||
// if (!updateListDataArray(elementId, { doNotAlert: false }))
|
// if (!that.updateListDataArray(elementId, { doNotAlert: false }))
|
||||||
// return
|
// return
|
||||||
if (!this.listData || this.listData.length == 0) {
|
if (!that.listData || that.listData.length == 0) {
|
||||||
alert("数组为空")
|
alert("数组为空")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -135,6 +136,7 @@ class ArrayVi extends ViBase {
|
|||||||
|
|
||||||
// 绘制数组
|
// 绘制数组
|
||||||
initArray(elementId, listData) {
|
initArray(elementId, listData) {
|
||||||
|
console.log("initArray")
|
||||||
let fragment = shape.getLinkedListFragment(elementId, listData, {
|
let fragment = shape.getLinkedListFragment(elementId, listData, {
|
||||||
x: 100,
|
x: 100,
|
||||||
y: 100,
|
y: 100,
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
<label>
|
<label>
|
||||||
请输入数组元素,以逗号分隔(中英文逗号均可)
|
请输入数组元素,以逗号分隔(中英文逗号均可)
|
||||||
<input id="array-input" style="width: 100%; text-align: center;" type="text" value="" />
|
<input id="array-input" style="width: 100%; text-align: center;" type="text" value="" />
|
||||||
</label>
|
</label>
|
||||||
<input id="getRandomBtn" type="button" value="随便来一个" />
|
<input id="getRandomBtn" type="button" value="随便来一个" />
|
||||||
</div>
|
</div>
|
||||||
<!-- 排序算法按钮 -->
|
<!-- 排序算法按钮 -->
|
||||||
|
Reference in New Issue
Block a user