Vue realizes an example of reading a full text function for too long?


.BodyFont {.FONT- DPR (16px); color: # 333; text-align: Left; line-height: 58px; Word-break: Break-all; Word-Wrap: Break-Word; Padding-Bottom: 30px; Height: Auto; Overflow: Hidden; Max-height: 100%; p {margin: 16px 0 0 0 0;}} .bodyHeight}} .BodyHeight {Height: 5000px;} .contettoggle {height: 60px; line-height: 60px; text-align: center; color: @ @ @ @ h;; color: @ Red; border: 1px solid @red; border-radius: 5px; .font-dpr (14px); margin-bottom: 30px;}

DATA () {Return {ContentStatus: False, Curheight: 0, BodyHeight: 5000}}, mounted () {setTimeout (() => {this .contentToggle ();}, 500)}, methods: {contentToggle () {this.curHeight = this $ refs.bodyFont.offsetHeight; if (this.curHeight> this.bodyHeight) {this.contentStatus = true;.} else { THISTENTSTATUS = false;}},}

The effect is as shown in the figure:

   Implementation of ideas and attention: 
1. After the content is high, after the DOM load is complete, add a settimeout function in MOUNTED, and ensure that it can really get

2. When the height of the content is higher than the height set to show, it is only limited to the height of yourself to show, add a Class to solve, pay attention to overflow: hidden;

Vue realizes that the article is too long. The instance of reading a full text function is the full content of Xiaobian sharing, I hope I can give you a reference, I hope everyone will support Tumi Cloud.


© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment