function Fn(str){
  this.str = str;
} 
Fn.prototype.format = function(){
  var arg = arguments;
  var dd =  this.str.replace(/{[0-9]}/g,function(a,b){
    var _index = a.replace(/\{|}/g,'');
    console.log(_index);
    return arg[_index]||''
  })
  return dd;
}

var fn = new Fn('<p><a href="{0}">{1}</a></p>')
document.write (fn.format('http://www.baidu.com/','百度'));

 

相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2021-06-08
  • 2022-02-13
  • 2021-11-30
  • 2021-12-03
  • 2021-10-10
猜你喜欢
  • 2021-11-08
  • 2021-06-05
  • 2021-06-24
  • 2021-08-06
  • 2021-06-23
  • 2021-06-20
相关资源
相似解决方案