直接放代碼spa
// 獲取焦點 focusInput() { let commentDom = document.querySelector('#textarea') setTimeout(function() { commentDom.scrollIntoView(true); commentDom.scrollIntoViewIfNeeded(); }, 500) },
在使用的input 或者textarea 須要被鍵盤頂起來,被頂起來的容器元素id爲textareacode
以上若是還不能夠,在作第二步操做:給這個元素設置position:stickyblog