【问题标题】:adding https:// in return statement in javascript在javascript中的return语句中添加https://
【发布时间】:2020-07-20 21:31:57
【问题描述】:

我有一个要求,我需要返回“https://hostname:port/context”。

formulas: {
     url: function(get) {
          return get('protocol') + ':' + get('hostname') + ':' + get('port') + '/' + get('webcontext');
     }
}

谁能建议我如何做到这一点?

【问题讨论】:

    标签: javascript extjs data-binding


    【解决方案1】:

    你可以使用Ext.String.format。我建议你使用默认值。

    formulas: {
       url: function(get) {
           return Ext.String.format('{0}://{1}:{2}/{3}',
              get('protocol') || 'https',
              get('host') || 'localhost',
              get('port') || 80,
              get('context') || '')
    
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-02
      • 2014-12-02
      • 1970-01-01
      • 2017-12-24
      • 1970-01-01
      相关资源
      最近更新 更多