【发布时间】:2019-06-08 22:59:45
【问题描述】:
我正在尝试移动父组件内的 Popper。我该怎么办?
我尝试在修饰符对象中使用偏移属性。 例如:
offset: {
offset: 20,
}
但 offset 只会将 Popper 朝一个方向移动。如果展示位置={'top' || 'bottom'} => 如果placement={'right' || 它会左右移动'left'} => 它上下移动。
const Layer = ({
children,
align,
inner = true,
parent,
portal,
}) => (
<Manager>
<Popper
placement={align}
modifiers={{
inner: {
enabled: inner,
},
}}
referenceElement={parent}
>
{({ ref, style, placement }) => (
<div
ref={ref}
data-placement={placement}
style={style}
>
{console.log(style)}
{children}
</div>
)}
</Popper>
</Manager>
)
【问题讨论】: