02.详细方法
check(index)
选中某个按钮 注意:在button-group中按钮的下标是从1开始的
<button-group dir="h" id="mGroup">
<button text="按钮1"/>
<button text="按钮2"/>
<button text="按钮3"/>
</button-group>
//找到按钮组
let mGroup = ui.id("mGroup");
//选中第2个按钮
mGroup.check(2);
onCheck((index)=>{})
设置按钮选中监听回调
<button-group dir="h" id="mGroup">
<button text="按钮1"/>
<button text="按钮2"/>
<button text="按钮3"/>
</button-group>
//找到按钮组
let mGroup = ui.id("mGroup");
//选中第2个按钮
mGroup.onCheck((index) => {
toast("选中了第" + index + "个按钮");
});