TS设置css属性

    const elStyle = document.documentElement.style
    elStyle.setProperty('--popper-bottom', String(buttonRect.bottom) + 'px')
    elStyle.setProperty('--popper-right', String(window.innerWidth - buttonRect.right) + 'px')
    // popper.style.setProperty(
    //   'inset',
    //   `${buttonRect.bottom}px ${window.innerWidth - buttonRect.right}px auto auto `,
    //   '!important',
    // )
    // popper.style.inset = `${buttonRect.bottom}px auto auto ${buttonRect.left}px !important`
    colorPickerRef.value?.show()

:global(.color-popper) {
  inset: var(--popper-bottom, 0px) var(--popper-right, 0px) auto auto !important;
  // v-bind只作用于scope
  // inset: v-bind(popperBottomRef) v-bind(popperRightRef) auto auto !important;
}

注释部分的方法不生效


评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注