Component({ properties: { title: String, type: { type: String, value: "default", //默认类型 switch-开关 }, switchLabel: String, //开关标签,type==switch生效 switch: Boolean, //开关属性值,type==switch生效 callBack: Function }, methods: { /* 改变开关状态 */ changeSwitch() { let showAll = !this.data.switch; this.setData({ switch: showAll }) this.triggerEvent("callBack", showAll) } } })