setStyle() {
//获取标签 el-popover
let elPopovers = document.querySelectorAll(".el-popover");
elPopovers.forEach((item) => {
var styles = getComputedStyle(item);
var width = styles.getPropertyValue("width");
// 监听里面样式变化
new MutationObserver((mutationsList) => {
mutationsList.forEach((mutation) => {
if (mutation.attributeName == "style") {
item.style.width = "auto"; // 设置宽度自动
item.style.minWidth = width;
}
});
}).observe(item, { attributes: true });
});
},
动态设置element 组件样式
于 2024-01-25 16:25:02 首次发布