Como mostrado abaixo:
<strong> Existe uma classe StringBuffer em Java, mas não há seguidores para implementar uma classe StringBuffer simples para JS. </strong> // Crie uma classe StringBuffer. Existem dois métodos para esta classe: um é o método de apêndice e o outro é a função do método tostring stringbuffer () {this .__ strings__ = [];}; stringbuffer.prototype.append = function (str) {this .__ strings __. Push (str);}; this .__ Strings __. Junção ('');};Uso de StringBuffer:
// Esta instância é usada principalmente para unir strings
function gnComcard (Companymsg) {var buffer = new StringBuffer (); // Declare um buffer de objeto.append ('<li>'); // Adicione uma string, o mesmo que buffer.append ('<div> <a href = "#"> <img src = "'); buffer.append (Companymsg.Userphoto); buffer.append ('"> </mg> </a> </div> '); buffer.append (' <div> '); buffer.append (' <div> <a>); buffer.append ('<div> <agus>' Compassg.com ('+ <a-Amanesg..com (' <apn> <div> <apform..comsg ('<ant> <a>); buffer.append (' <div> <a> ''+. Formatdate (Companymsg.crtime)+ '</span> </div>'); buffer.append ('</div> <div>'); if (Companymsg.newsid! = Null) {buffer.apmen; {{buffer.Append ('<a href = "javascript: void (0)">' + Companiesg.NewStitle + '</a>');} if (Companymsg.NewScontent! '</div>');} buffer.append ('</div>'); buffer.append ('</div>'); buffer.append ('<div> <a href = "javascript: void (0)" style = "float: esquerd"> </span> </aa> <input type = "text"> </input> </div> '); buffer.append (' </div> </li> '); retornar buffer.toString (); // dividido em uma string}O artigo acima discute brevemente o método de implementação e o uso da classe StringBuffer no JS. Este é todo o conteúdo que compartilhei com você. Espero que você possa lhe dar uma referência e espero que você possa apoiar mais o wulin.com.