cyan
尝试做了个例子,具体代码如下:
最后表示出来的结果里,左上角的一个Title为Left的子view上点击,是没有反馈的。
还请有时间帮忙解答一下,非常感谢。
$ui.render({
views: [
{
type: "view",
props: {
bgcolor: $color("#FF0000")
},
layout: function (make, view) {
make.center.equalTo(view.super)
make.size.equalTo(view.super)
},
views: [
{
type: "view",
props: {
id: "superview",
bgcolor: $color("#FFFF00")
},
layout: function (make, view) {
make.top.equalTo(view.super)
make.width.equalTo(view.super)
make.height.equalTo(200)
},
events: {
// tapped: function (sender) {
// $ui.toast("Mainviews tapped!");
// },
ready: function (sender) {
loadSubviews()
}
},
}
]
}
]
})
function loadSubviews() {
const superview = $("superview")
var subview = $ui.create({
type: "view",
views: [
{
type: "view",
views: [
{
type: "label",
props: {
text: "Left",
align: $align.center,
frame: $rect(0, 0, 100, 100),
bgcolor: $color("silver")
},
events: {
tapped: function (sender) {
$ui.toast("Subviews tapped!");
}
}
}
]
},
]
})
superview.add(subview)
superview.layout((make, view) => {
});
}