아래 그림과 같이 :
<strong> Java에는 StringBuffer 클래스가 있지만 JS에 대해 간단한 StringBuffer 클래스를 구현할 수있는 다음은 없습니다. </strong> // StringBuffer 클래스를 만듭니다. 이 클래스에는 두 가지 방법이 있습니다. 하나는 부록 방법이고 다른 하나는 tostring 메소드 함수 stringbuffer () {this .__ strings__ = [];}; StringBuffer.prototyp.append = function (str) {this .__ Strings __. push (str);}; stringbuffer.prototype.toString = function ();StringBuffer 사용 :
//이 인스턴스는 주로 문자열 스플 라이스에 사용됩니다
function gncomcard (compolyymsg) {var buffer = new StringBuffer (); // 객체 버퍼를 선언합니다. src = " '); buffer.append (compolymsg.userphoto); buffer.append ('"> </img> </a> </div> '); buffer.append ('<div> '); buffer.append ('<div> <a> ''); buffer.append ( '<av> <a>'+ '+'+ '+'+ formatdate (compolyymsg.crtime)+ '</span> </div>'); buffer.append ( '</div> <div>'); if (componymsg.newsid! = null) {buffer.append ( '<a href = "'+ compolyymsg.newsid+ '">'+ Companiesg.newstitle+ '</>); {buffer.append ( '<a href = "javaScript : void (0)">' + companiesg.newstitle + '</a>');} if (componyMsg.newScontent! = null) {buffer.Append ( '<<div> <span >> expan </span> </div>'; bubspend.Append.Append. '</div>');} buffer.append ( '</div>'); buffer.append ( '</div>'); buffer.append ( '<div> <a href = "javaScript : void (0)"스타일 = "float : left"> <span> </span> </a> input type = "text"> </input> </div> '); buffer.append ('</div> </li> '); return buffer.toString (); // 문자열로 분할}위의 기사는 JS에서 StringBuffer 클래스의 구현 방법과 사용에 대해 간략하게 설명합니다. 이것은 내가 당신과 공유 한 모든 콘텐츠입니다. 나는 당신이 당신에게 참조를 줄 수 있기를 바랍니다. 그리고 당신이 wulin.com을 더 지원할 수 있기를 바랍니다.