我希望重新定位弹出框位置 - 目前在圆形 SVG 右侧 - 基于用户在 CircleSVG 内的鼠标位置(单击时)或将其移动到 SVG 的正中心(同时移动弹出框内容和箭头)。能否动态更改?
const popover = new bootstrap.Popover(document.getElementById("test"), {
html: true,
sanitize: false,
trigger: 'manual',
content: 'Nice'
});
function togglePopover() {
popover.toggle();
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
<svg onclick="togglePopover()" height="100" width="100">
<circle id="test" cx="50" cy="50" r="40" stroke="black" stroke width="3" fill="red" />
</svg>