// components/popup/popup.js Component({ /** * 组件的属性列表 */ properties: { // 是否弹出显示 visible: { type: Boolean, value: false }, //点击外部的遮罩层是否允许关闭 outClickCanClose: { type: Boolean, value: false }, // 组件循环需要渲染的数据内容, 接受label和value的形式 data: { type: Array, value: [ { label: '是', value: 1 },{ label: '否', value: 0 } ] } }, /** * 组件的初始数据 */ data: { }, /** * 组件的方法列表 */ methods: { closePopup() { this.triggerEvent("close", { visible: this.data.visible }) }, outClick(){ if (this.data.outClickCanClose){ this.triggerEvent("close", { visible: this.data.visible }) } }, ok(e){ this.triggerEvent("ok", e.target.dataset.value) } } })