@@ -264,17 +264,21 @@ export default (Vue as VueConstructor<Vue & {
264264 /** 定位下拉框 */
265265 locateDropdown (): void {
266266 const referenceRect = this .$refs .reference .getBoundingClientRect ()
267- const referenceWidth = referenceRect .right - referenceRect . left
268- const referenceHeight = referenceRect .bottom - referenceRect . top
267+ const referenceWidth = referenceRect .width
268+ const referenceHeight = referenceRect .height
269269
270270 // Set dropdown width
271271 const minWidth = ` ${typeof this .dropdownMinWidth === ' number' ? this .dropdownMinWidth : referenceWidth }px `
272272 this .$refs .dropdown .style .minWidth = minWidth
273273 this .$refs .dropdown .style .width = this .dropdownWidthFixed ? minWidth : ' auto'
274274
275275 const dropdownRect = this .$refs .dropdown .getBoundingClientRect ()
276- const dropdownWidth = dropdownRect .right - dropdownRect .left
277- const dropdownHeight = dropdownRect .bottom - dropdownRect .top
276+ const dropdownStyleDeclaration = window .getComputedStyle (this .$refs .dropdown )
277+ const dropdownMarginHorizontal = parseFloat (dropdownStyleDeclaration .marginLeft ) + parseFloat (dropdownStyleDeclaration .marginRight )
278+ const dropdownMarginVertical = parseFloat (dropdownStyleDeclaration .marginTop ) + parseFloat (dropdownStyleDeclaration .marginBottom )
279+ const dropdownWidth = dropdownRect .width + dropdownMarginHorizontal
280+ // 0.8 这个值写在 css 里,因为有动画,所以获取到的是 scaleY 变换后的值
281+ const dropdownHeight = dropdownRect .height / 0.8 + dropdownMarginVertical
278282 let top = 0
279283 let left = 0
280284 if (this .transfer ) {
@@ -302,7 +306,7 @@ export default (Vue as VueConstructor<Vue & {
302306 case ' bottom' :
303307 if (this .transfer ) {
304308 top = window .pageYOffset + referenceRect .bottom
305- left = window .pageXOffset + referenceRect .right - dropdownWidth
309+ left = ( window .pageXOffset + referenceRect .right - dropdownWidth ) / 2
306310 } else {
307311 top = referenceHeight
308312 left = (referenceWidth - dropdownWidth ) / 2
@@ -328,7 +332,7 @@ export default (Vue as VueConstructor<Vue & {
328332 case ' top' :
329333 if (this .transfer ) {
330334 top = window .pageYOffset + referenceRect .top - dropdownHeight
331- left = window .pageXOffset + referenceRect .right - dropdownWidth
335+ left = ( window .pageXOffset + referenceRect .right - dropdownWidth ) / 2
332336 } else {
333337 top = - dropdownHeight
334338 left = (referenceWidth - dropdownWidth ) / 2
0 commit comments