need-miniprogram-ui
Version:
小程序UI组件库
1 lines • 746 B
JavaScript
Component({options:{virtualHost:!0,styleIsolation:"isolated",multipleSlots:!0},properties:{placement:{type:String,value:"bottom"},glass:{type:Boolean,value:!1}},data:{visible:!1,popoverStyle:""},methods:{tap:function(){var a=this;this.setData({visible:!0}),wx.nextTick(function(){var t=a.createSelectorQuery();t.select("#popover-wrap").boundingClientRect(),t.select("#popover").boundingClientRect(),t.exec(function(t){var e,o;t&&t.length&&(e=t[0],o="left:".concat(e.left-((t=t[1]).width-e.width)/2,"px;"),"bottom"===a.data.placement&&(o+="top:".concat(e.top+e.height+18,"px;")),"top"===a.data.placement&&(o+="top:".concat(e.top-t.height-18,"px;")),a.setData({popoverStyle:o}))})})},close:function(){this.setData({popoverStyle:"",visible:!1})}}});