查看api 后 horizontalDirection 的值是 Layout.HorizontalDirection枚举
所以直接用索引下标
setLayout(type = 0){
let number = type;
this.mainNode.getComponent(cc.Layout).horizontalDirection = number;
this.isBuffNode.getComponent(cc.Layout).horizontalDirection = number;
},