gpt4 book ai didi

javascript - 祝福名单失败

转载 作者:行者123 更新时间:2023-11-30 12:34:57 25 4
gpt4 key购买 nike

我正在尝试制作一个简单的列表框。

var blessed = require("blessed");

// Create a screen object.
var screen = blessed.screen();

// Create a box perfectly centered horizontally and vertically.
var serverList = blessed.list({
align: "center",
mouse: true,
width: "50%",
height: "50%",
top: "center",
left: "center",
items: [
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten"
]
});

// Append our box to the screen.
screen.append(serverList);
serverList.select(0);

// Quit on Escape, q, or Control-C.
screen.key(["escape", "q", "C-c"], function(ch, key) {
return process.exit(0);
});

// Focus our element.
serverList.focus();

// Render the screen.
screen.render();

根据文档和 chjj/blessed/test/widget.js这应该是我所需要的。但它只是错误地说它无法读取高度。这是错误。

TypeError: Cannot read property 'height' of null
at ScrollableBox.Element._getTop (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:2595:17)
at ScrollableBox.Element._getBottom.parent [as top] (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:2617:15)
at Box.Element._getTop (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:2613:17)
at Box.Element._getBottom.parent [as top] (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:2617:15)
at Screen._focus (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:1439:19)
at Screen.focusPush (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:1389:8)
at Screen.clearRegion [as focused] (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:1467:15)
at ScrollableBox.Node.insert (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:86:25)
at ScrollableBox.Node.append (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:95:8)
at ScrollableBox.List.add.List.addItem.List.appendItem (/home/giodamelio/Projects/real/Vindinium-Bots/node_modules/blessed/lib/widget.js:4262:8)

最佳答案

它看起来像 blessed 中的错误。如果您在 blessed.list() 选项中手动指定 parent: screen,它将起作用。由于某种原因,它不会自动确定父级。

您链接到测试的原因是因为首先将其他小部件添加到屏幕,这意味着列表肯定会设置其parent(到先前添加的小部件)。

关于javascript - 祝福名单失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26348592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com