[Improvement] NoticeBar: add ref check (#1037)

This commit is contained in:
neverland 2018-05-10 20:41:15 +08:00 committed by GitHub
parent a92fa7d4a8
commit 8424b51aff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,8 +90,13 @@ export default create({
text: {
handler() {
this.$nextTick(() => {
const offsetWidth = this.$refs.content.getBoundingClientRect().width;
const wrapWidth = this.$refs.wrap.getBoundingClientRect().width;
const { wrap, content } = this.$refs;
if (!wrap || !content) {
return;
}
const wrapWidth = wrap.getBoundingClientRect().width;
const offsetWidth = content.getBoundingClientRect().width;
if (this.scrollable && offsetWidth > wrapWidth) {
this.wrapWidth = wrapWidth;
this.offsetWidth = offsetWidth;