假设根据从列表组中选择的孩子来放置不同的结果,这是我只是想弄清楚基础知识。最终,类似的结构将根据从列表框中选择的子项,使用不同的数据填充多个流这是我的代码:
Shoes.app do
para "Choose which child:"
list_box :items => ["child 1", "child 2", "child 3"],
:width => 120,
:choose => "child 1" do |list|
@child.text = list.text
end
@child = para "child 1"
flow width:0.5, height: 0.5 do
if @child.text = choose(item: "child 1")
para "you got this"
elsif @child.text = "child 2"
para "yes!!!"
else
para "think..think"
end
end
end
试试这个,让我知道它是否像你预期的那样工作。我希望我答对了你的问题。
require 'green_shoes'
Shoes.app do
para "Choose which child:"
list_box items: ["child 1", "child 2", "child 3"],
:width => 120, choose: "child 1" do |list|
@child.text = list.text
if @child.text == "child 1"
@test_stack.clear
@test_stack.append {para "you got this"}
elsif @child.text == "child 2"
@test_stack.clear
@test_stack.append {para "yes"}
else
@test_stack.clear
@test_stack.append {para "think..think"}
end
end
@child = para "child 1"
@test_stack = stack width: 0.5, height: 0.5 do
para "you got this"
end
end
此外,使用双等号进行条件检查。并且你必须调用列表框内的条件更改。至于插槽操作,我通常会清除它,然后附加到它,如上所述。
我用的是绿鞋,但这无关紧要,只是忽略了要求。
问候
塞巴