Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法设置input的letter-spacing样式 #485

Closed
mrtugit opened this issue Jun 21, 2019 · 1 comment
Closed

无法设置input的letter-spacing样式 #485

mrtugit opened this issue Jun 21, 2019 · 1 comment

Comments

@mrtugit
Copy link

mrtugit commented Jun 21, 2019

`_initInputStyle () {
const wrapper = this.$refs.wrapper
const computedStyle = window.getComputedStyle(wrapper)
const rectStyle = wrapper.getBoundingClientRect()
const inputElem = this.$refs.input
const placeholderElem = this.$refs.placeholder

  // 获取到的高度为 0 则认为组件未渲染,通常是使用 v-show 时会出现此情况。
  if (!rectStyle.height) {
    return
  } else {
    this.isRendered = true
  }
  // 渲染之后进行计算,设置实际的高度等样式。
  const realHeight = rectStyle.height - (parseFloat(computedStyle.borderTopWidth, 10) + parseFloat(computedStyle.borderBottomWidth,
    10))
  if (realHeight !== this.wrapperHeight) {
    inputElem.style.height = `${realHeight}px`
    inputElem.style.lineHeight = `${realHeight}px`
    this.wrapperHeight = realHeight
  }
  // inputElem.style.color = computedStyle.color

  placeholderElem.style.height = `${realHeight}px`
  placeholderElem.style.lineHeight = `${realHeight}px`
}`

这部分代码是不是初始化了样式?
我在外面无法设置 letter-spacing 。有什么办法可以解决这个问题吗?

@LOUSANPANG
Copy link

还是无法设置letter-spacing样式

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants