鍍金池/ 問答
生性 回答

因?yàn)閒n是個(gè)匿名函數(shù)

舉個(gè)簡(jiǎn)單例子

    var obj = {
        fn1: function() {
            console.log(this);//此處輸出obj本身
            var noNamed = function() {
                console.log(this);//此處輸出windowd對(duì)象
            };
            return noNamed();
        }
    };
    obj.fn1();

以上,你的var fn=function(){};return fn()本質(zhì)上就是個(gè)直接調(diào)用的匿名函數(shù)閉包 return function(){}
你只是將這個(gè)匿名函數(shù)賦值給fn了,并不能改變他沒函數(shù)名的本質(zhì)

結(jié)論:只要是匿名函數(shù),this就指向window全局對(duì)象,例如:

function foo() {
    var fn = setTimeout(function() { //我是匿名函數(shù)
        console.log(`setTimeout的this不會(huì)隨foo改變:${this.age}`); 
    }, 0);
}
foo.call({
    age: '1000'
});//輸出undefined
傻叼 回答
  1. fn返回的是一個(gè)數(shù)組,所以結(jié)果肯定是一個(gè)多維數(shù)組
  2. concat只能接受數(shù)組作為參數(shù),"..."運(yùn)算之后就不是數(shù)組了。
const flatten = (arr, depth = 1) =>
 arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), > []);

來源:flatten

凝雅 回答

為什么要用 file_get_contents ?沒用框架?那直接用html表單上傳,后臺(tái)用$_FILES看看速度如何

女流氓 回答

this.keys["similar"] = similar;
this.keys["relative"] = relative;

  1. 為什么第一處typeof是"undefined"?
    obj是個(gè)實(shí)例對(duì)象,默認(rèn)沒有prototype
  2. 為什么第二處的prototype是object?
    第二處你用的是一個(gè)funtion,function默認(rèn)有prototype,并且默認(rèn)其下只有一個(gè)constructor屬性指向自己。
  3. 為什么最后一處是false?
    Object.create創(chuàng)建了一個(gè)新的object,具體實(shí)現(xiàn)方式類似于下面

      Object.create =  function (o) {
          var F = function () {};
          F.prototype = o;
          return new F();
      };
淚染裳 回答
const reducer = (state = {}, action) => {
    switch (action.type) {
        case 'chinese':
            return {
                ...state,
                ...{msg: '這是Redux啊'}
            }
        case 'english':
            return {
                ...state,
                ...{msg: "This is Redux"}
            }
        default:
            return state
    }
}

改成這樣

安若晴 回答

已解決.. 使用多個(gè)serviceId可以解決這種情況;
后面會(huì)整理發(fā)出;

parse相關(guān)函數(shù), 處理url parse_url(), 處理?后面帶的數(shù)據(jù) parse_str()


$url        = 'http://www.abc.com/?title=ww&imgFile=%2Fpublic%2Fupload%2Fimage%2F20180712%2F20180712024544_27715.jpg';
$urlArray   = parse_url($url);
print_r($urlArray);
parse_str($urlArray['query'], $paramList);
print_r($paramList);
exit;

結(jié)果

Array
(
    [scheme] => http
    [host] => www.abc.com
    [path] => /
    [query] => title=ww&imgFile=%2Fpublic%2Fupload%2Fimage%2F20180712%2F20180712024544_27715.jpg
)
Array
(
    [title] => ww
    [imgFile] => /public/upload/image/20180712/20180712024544_27715.jpg
)
念舊 回答

static,靜態(tài)變量,了解一下。

舊酒館 回答

"css-loader",
"postcss-loader",

改為:

{loader: 'css-loader',options: { importLoaders: 1 }},
{loader: 'postcss-loader',options: { config: { path: path.resolve(__dirname, './postcss.config.js') } },

我是在這里找到的答案:
https://github.com/webpack-co...

嘟尛嘴 回答

1 先用正則表達(dá)式,按照 數(shù)字冒號(hào)(1:,2:)拆分單條信息
得到結(jié)果:
[
'1:公司名:An網(wǎng)站:wwwn電話:123456789n',
'2:公司名:An網(wǎng)站:wwwn電話:123456789nn',
'3:公司名:An網(wǎng)站:wwwn電話:123456789地址:abbn',
'4:公司名:An網(wǎng)站:wwwn電話:123456789',
]

2 取出每一項(xiàng)目,將數(shù)字冒號(hào)(1:)替換為空
如:'1:公司名:An網(wǎng)站:wwwn電話:123456789n',

3 按照n拆分,再按照:區(qū)分鍵值對(duì)。
如:'公司名:An網(wǎng)站:wwwn電話:123456789n',
得到結(jié)果:[{'公司名':'A'},{'網(wǎng)站':'www'},{'電話':'123456789'}]

你好胸 回答

Web App側(cè)重“功能”,是使用網(wǎng)頁技術(shù)實(shí)現(xiàn)的App??偟膩碚f,Web App就是運(yùn)行于網(wǎng)絡(luò)和標(biāo)準(zhǔn)瀏覽器上,基于網(wǎng)頁技術(shù)開發(fā)實(shí)現(xiàn)特定功能的應(yīng)用。比如谷歌搜索引擎就是一個(gè)webApp,它有一個(gè)特定的功能,所以可以稱為webapp
https://baike.baidu.com/item/...

PWA可以添加至主屏幕,點(diǎn)擊主屏幕圖標(biāo)可以實(shí)現(xiàn)啟動(dòng)動(dòng)畫以及隱藏地址欄,實(shí)現(xiàn)離線緩存功能,即使用戶手機(jī)沒有網(wǎng)絡(luò),依然可以使用一些離線功能,實(shí)現(xiàn)了消息推送。
https://segmentfault.com/a/11...

執(zhí)念 回答

CSS:before and after

久礙你 回答
browserSync.init({
                server:{
                    baseDir:paths.source.root
                },
                open:"external"  //自己瀏覽器的IP
            });

Java中的label標(biāo)記,類似于C語言的goto,可能是object:迷惑了你,你可以任意寫一個(gè)字符串(非關(guān)鍵字)都能編譯通過。

薔薇花 回答
export class HeaderComponent implements OnInit {
    private timer = 0;
    public settingDialog = false;
    
    ...
    toggleSetting(isShow: any) {
        const show = !!isShow;
        clearTimeout(this.timer);
        if (!show) {
            // delay 600ms for hide
            this.timer = setTimeout(() => {
                this.settingDialog = show;
            }, 600);
            return;
        }
        this.settingDialog = show;
    }
    ...
}