// components/modalView/index.js Component({ /** * 组件的属性列表 */ properties: { titleText:{ type:String, value:'' }, titleTextCenter:{ type:Boolean, value:true }, editable:{ type:Boolean, value:false }, content:{ type:String, value:'' }, contentPlaceholder:{ type:String, value:'请输入内容' }, isShowCancel:true, cancelButtonText:{ type:String, value:'取消' }, okButtonText:{ type:String, value:'确定' }, show:{ type:Boolean, value:false } }, /** * 组件的初始数据 */ data: { dynamicsStyle:'' }, /** * 组件的方法列表 */ methods: { cancelButtonTap(){ this.setData({ show:false }); this.triggerEvent('cancel'); }, okButtonTap(){ this.setData({ show:false }); this.triggerEvent('ok'); } }, lifetimes:{ attached(){ const windowInfo = wx.getWindowInfo(); const viewHeight = 50+96+32+48; this.setData({ dynamicsStyle:`top:${(windowInfo.windowHeight-viewHeight)/2}px;height:${viewHeight}px;` }) } } })