Members
(constant) Update component properties
The setProps function allows users to update multiple properties of a component instance simultaneously by passing an object containing key-value pairs of the properties to be updated.
# Suppose there is a button named Button_1 in the workspace.
# 假设工作区中有一个名为Button_1的按钮
// Toggle the button to enable it and then set the button text.
// 切换按钮的启用状态并设置文本
Instance.Button_1.setProps({
text: 'ABB robot', // 设置按钮文本为“ABB robot”
height: 100, // 设置高度为100
width: 100, // 设置宽度为100
font: {
fontSize: 20, // 设置字体大小为20
fontFamily: '微软雅黑', // 设置字体为微软雅黑
style: {
fontStyle: 'italic', // 设置字体为斜体
fontWeight: 'bold', // 设置字体加粗
textDecoration: 'underline', // 设置文本下划线
},
},
backgroundColor: 'rgb(255,0,0)', // 否则改为红色
onClick: () => {
TComponents.Popup_A.message('onClick');
console.log('onClick');
}, // 点击按钮时弹窗显示 "onClick"
onPointerDown: () => {
TComponents.Popup_A.message('onPointerDown');
console.log('onPointerDown');
}, // 点击按钮时弹窗显示 "onPointerDown"
onPointerRelease: () => {
TComponents.Popup_A.message('onPointerRelease');
console.log('onPointerRelease');
}, // 点击按钮时弹窗显示 "onPointerDown"
});