<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ``` //=>時間字符串格式化 // "2018/4/30 17:50:23" => "04-30 17:50" //=>簡單處理 // let str = "2018/4/30 17:50:23", // ary = str.split(/(?:\/| |:)/g); // // console.log(ary);//=>["2018", "4", "30", "17", "50", "23"] // let [, month, day, hours, minutes] = ary, // result = `${month}-${day} ${hours}:${minutes}`; // console.log(result); // let str = "2018/4/30 17:50:23"; // //1.獲取時間字符串中的所有數字 (SPLIT) // let ary = str.match(/\d+/g).map(item => { // return item < 10 ? '0' + item : item; // });//=>MAP相對于FOR-EACH來講多了返回值, // 函數中RETURN的是啥,就是把當前數組中迭代的這一項替換成啥 // // console.log(ary);//=>["2018", "04", "30", "17", "50", "23"] //2.指定最后想要的時間格式,我們基于這個數組中的內容,幫你拼接好即可 // let template = '{0}年{1}月{2}日 {3}時{4}分{5}秒'; // //=>{0} / 0 =>'2018' ARY[0] // //=>{1} / 1 =>'04' ARY[1] // //=>... // template = template.replace(/\{(\d)\}/g, (...arg) => { // let [, index] = arg;//=>index:每一次正則匹配小分組捕獲的結果(也就是那個數字) // return ary[index]; // }); // console.log(template); //=>時間字符串格式化 String.prototype.myFormatTime = function myFormatTime(template = '{0}年{1}月{2}日 {3}時{4}分{5}秒') { let ary = this.match(/\d+/g).map(item => (item < 10 ? '0' + item : item)); return template.replace(/\{(\d)\}/g, (...[, index]) => ary[index] || '00'); }; let str = "2018-4-30"; console.log(str.myFormatTime('{1}-{2} {3}:{4}')); //=>思考題 //1. 獲取一個字符串中最多出現字符的次數和對應的字符 // let str = 'zhufengpeixunzhouxiaotianzuishuai'; //2. 獲取URL問號后面的參數值 // let str = 'http://www.zhufengpeixun.cn/stu/?name=AA&age=25&sex=0#teacher'; //=>{name:'AA',age:25,sex:0,HASH:'teacher'} ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看