ant-design-vue
ant-design-vue copied to clipboard
mentions组件支持autoSize功能
trafficstars
- [ ] I have searched the issues of this repository and believe that this is not a duplicate.
What problem does this feature solve?
输入较多内容时候可以自动调节高度
What does the proposed API look like?
autoSize
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
自己本地hack了
// textarea 就是mentions 里面那个textarea
let tmp:any = null
export function autoHeight(textarea: any, minHeight = 88, maxHeight = 176) {
const style = getComputedStyle(textarea)
tmp = tmp || document.createElement('div')
tmp.style.width = style.width
tmp.style.lineHeight = style.lineHeight
tmp.style.fontSize = style.fontSize
tmp.style.whiteSpace = 'break-spaces'
tmp.style.position = 'fixed'
tmp.style.pointerEvents = 'none'
tmp.style.wordBreak = 'break-all'
tmp.style.opacity = '0'
// tmp.style.top = '0'
// tmp.style.right = '120px'
// tmp.style.background = 'red'
// tmp.style.zIndex = `1000`
tmp.textContent = textarea.value
document.body.appendChild(tmp)
const newHeight = tmp.offsetHeight
textarea.style.height = `${Math.min(Math.max(minHeight, newHeight), maxHeight)}px`
//document.body.removeChild(tmp)
}
自己本地hack了
// textarea 就是mentions 里面那个textarea let tmp:any = null export function autoHeight(textarea: any, minHeight = 88, maxHeight = 176) { const style = getComputedStyle(textarea) tmp = tmp || document.createElement('div') tmp.style.width = style.width tmp.style.lineHeight = style.lineHeight tmp.style.fontSize = style.fontSize tmp.style.whiteSpace = 'break-spaces' tmp.style.position = 'fixed' tmp.style.pointerEvents = 'none' tmp.style.wordBreak = 'break-all' tmp.style.opacity = '0' // tmp.style.top = '0' // tmp.style.right = '120px' // tmp.style.background = 'red' // tmp.style.zIndex = `1000` tmp.textContent = textarea.value document.body.appendChild(tmp) const newHeight = tmp.offsetHeight textarea.style.height = `${Math.min(Math.max(minHeight, newHeight), maxHeight)}px` //document.body.removeChild(tmp) }
这是要写到node_modules下面的哪里了
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.