鍍金池/ 問答/ HTML問答
尛曖昧 回答

分辨率設(shè)置成默認(rèn) , mac 下是 win + 0

墻頭草 回答

el-form需要接收一個model,并且需要配合el-form-item一起使用,并且在el-form-item上綁定prop屬性,resetField方法才能好使。

<el-form :model="addServiceData" ref="addServiceForm">
    <el-form-item label="手機(jī)號" prop="mobile">
       <el-input v-model="data.mobile" placeholder="請輸入手機(jī)號碼"></el-input>
     </el-form-item>
</el-form>

并且addServiceData應(yīng)該是個對象,定義在data里面,類似這樣

data(){
    return {
        addServiceData: {
            mobile: ''
        }
    }
}
怣痛 回答

文檔里有寫啊

https://zh.nuxtjs.org/api

asyncData 可以接受一個 context 參數(shù),包含了當(dāng)前環(huán)境所有信息

context.store 就能獲取到 vuex 實例了,具體內(nèi)容打開鏈接進(jìn)去看吧

拮據(jù) 回答
找到問題所在了,大圖的寬應(yīng)該等于小圖寬乘以 放大圖的預(yù)覽圖除以放大鏡的寬, 高同理,上面的代碼自己改一部分就可以

*上面的

bigImage.width = bigImage.offsetWidth * percent;
bigImage.height = bigImage.offsetHeight * percent; 

改為

bigImage.width = container.offsetWidth * percent;
bigImage.height = container.offsetHeight * percent; 

即可,昨天寫到太晚,迷迷糊糊地沒發(fā)現(xiàn)

法克魷 回答

curl 能訪問就不是nodejs的問題了,應(yīng)該還是防火墻的問題,先看看端口通不通

telnet ip port
櫻花霓 回答

computed中的計算屬性需要有一個返回值,你這里看似有返回值,但是返回到哪里去了?

無論是then還是catch中的返回都是傳遞到Promise的下一個狀態(tài)中,不能作為provinceList的返回值,就是不拿es6的Promise來說,函數(shù)嵌套,內(nèi)層函數(shù)的返回值也不會作為外層函數(shù)的返回值返回出去

你這個可以在鉤子函數(shù)中請求到數(shù)據(jù)后,在賦值到provinceList上去

萢萢糖 回答

你需要看一下數(shù)組更新檢測
數(shù)組的更新,需要手動進(jìn)行更新

吃藕丑 回答

pc web端的直播跟node和php都沒有半毛錢關(guān)系。直接http hls要不就rtmp了。用腳本語言去處理視頻流數(shù)據(jù)太不適合了,有更加專業(yè)的ffmpeg和c和go

帥到炸 回答

感覺你不適合程序員......

孤星 回答

jquery 和 angular 的ajax請求上還是存在差異的

http://victorblog.com/2012/12...

提到在客戶端改變angularJS默認(rèn)傳輸格式為Content-Type: x-www-form-urlencoded。

放開她 回答

很清楚啊,input type不支持動態(tài),用v-if代替

<input v-if="isNewpwd" type="text" v-model='newPwd' placeholder="請輸入你的密碼"/>
<input v-else type="password" v-model='newPwd' placeholder="請輸入你的密碼"/>
脾氣硬 回答

請問解決了嗎?我也碰到了,是react的項目

糖豆豆 回答

使用 ES5 內(nèi)置數(shù)組函數(shù) + 箭頭函數(shù)隱藏 for 循環(huán)細(xì)節(jié)

packageInfoList.forEach(package => {
    var newPackage = ConfigData.getGoods(true, package.id);
    package.packageTag.forEach(tag => {
        var newTag = newPackage.packageTag.find(t => t.id === tag.id);
        if(!newTag) return;
        tag.goods.forEach(goods => {
            var newGoods = newTag.goods.find(g => g.id === goods.id);
            if(!newGoods) return;
            var flag = updateGoodAttr(goods, newGoods);
        });
    });
});

updateGoodAttr = (goods, newGoods) => {
    goods.attr.forEach(attr => {
        var newAttr = newGoods.attr.find(a => a.id === attr.id)
        attr.option.filter(taste => !!taste.select).foreach(taste => {
            var newTasteOption = newAttr.option.find(t => t.id === taste.id);
            if(newTasteOption) {
                newTasteOption.select = taste.select;
            }
        });
    });
}

提取重復(fù)的數(shù)組比對邏輯

已經(jīng)省去里很多迭代的下角標(biāo)處理里,但是代碼還是很啰嗦,頻繁重復(fù)對兩個數(shù)組進(jìn)行元素比較。干脆把這個邏輯提取出來:

var match = (arr1, arr2, identifier, process) => arr1.forEach(item1 => 
    arr2.forEach(item2 => identifier(item1) === identifier(item2) && process(item1, item2))
);

傳入兩個數(shù)組,對數(shù)組元素的每個元素使用 identifier 獲取 id,如果比較成功,則調(diào)用 process 函數(shù)處理這兩個元素。例子中 identifier 都一樣,即 item => item.id.

var ID = item => item.id;

var processPackage = (p1, p2) => match(p1.packageTag, p2.packageTag, ID, processTag);

var processTag = (tag1, tag2) => match(tag1.goods, tag2.goods, ID, processGoods);

var processGoods = (goods1, goods2) => match(goods1,attr, goods2.attr, ID, processAttr);

var processAttr = (attr1, attr2) => match(attr1.options.filter(taste => !!taste.select), attr2.options, ID, processTaste);

var processTaste = (taste1, taste2) => taste2.select = taste1.select


var packageInfoList = [...], configPackageList = [...];

match(packageInfoList, configPackageList, ID , processPackage);

消除重復(fù)調(diào)用

目前代碼中還存在重復(fù)地調(diào)用 match 函數(shù),調(diào)用邏輯相似而重復(fù),如果能把這塊抽出來就好了。我們再提取一個函數(shù),用來構(gòu)造 processXXXprocessAttr比較特殊,對兩邊取子屬性的邏輯不一樣,所以提取的這個函數(shù)需要考慮 processAttr 的需求。

var subProcess = ([s1, s2], id, process) => (i1, i2) => match(s1(i1), s2(i2), id, process)

var fixSelector = f => Array.isArray(f) ? f : [f, f]
var processTaste = (taste1, taste2) => taste2.select = taste1.select
var processAttr = subProcess(
    fixSelector([item => item.options.filter(taste => !!taste.select), item => item.options]), 
    ID,
    processTaste
)
var processGoods = subProcess(fixSelector(item => item.attr), ID, processAttr)
var processTag = subProcess(fixSelector(item => item.goods), ID, processGoods)
var processPackage = subProcess(fixSelector(item => item.tag), ID, processTag)


var ID = item => item.id
match(
    packageInfoList,
    configPackageList,
    ID,
    processPackage
);

最后一步調(diào)用其實等價于:

subProcess(fixSelector([() => packageInfoList, () => configPackageList], ID, 
    subProcess( fixSelector(package => package.tag), ID
        subProcess( fixSelector(tag => tag.goods), ID,
            subProcess( fixSelector(goods => goods.attr), ID
                subProcess( fixSelector([attr => attr.options.filter(taste => !!taste.select), attr => attr.options]), ID
                    processTaste
                )
            )   
        )          
    )
)()

把掉套函數(shù)調(diào)用拉平試試?試想如下代碼:

f(a, f(b, f(c, f(d, e)))))

// 等價于

[a,b,c,d,e].reduceRight((prev, item) => f(item, prev))

于是有:

var match = (arr1, arr2, identifier, process) => arr1.forEach(item1 => 
    arr2.forEach(item2 => identifier(item1) === identifier(item2) && process(item1, item2))
)
var subProcess = ([s1, s2], id, process) => (i1, i2) => match(s1(i1), s2(i2), id, process)
// 為了傳遞 selector 的時候可以單獨給一個函數(shù)
var fixSelector = f => Array.isArray(f) ? f : [f, f]
var reducer = (prev, [selector, identifier]) => subProcess(fixSelector(selector), identifier, prev)
var process = (...items) => items.reduceRight(reducer)()


// 調(diào)用
process(
    [ [() => packageInfoList, () => configPackageList], ID], // 初始數(shù)據(jù)
    [ package => package.tag, ID], // 根據(jù)上面一項的元素,返回需要繼續(xù)比對的下一層數(shù)據(jù)
    [ tag => tag.goods, ID], // 把ID當(dāng)參數(shù)在每一層傳進(jìn)來是為了支持不同層取 ID 的方式不同
    [ goods => goods.attr, ID], // 再深也不怕,無非多一個參數(shù)
    // 支持兩邊不同的取值方法
    [ [attr => attr.options.filter(taste => !!taste.select), attr => attr.options], ID], 
    // 最后一個函數(shù)就是你處理深處數(shù)據(jù)的地方啦
    (taste1, taste2) => taste2.select = taste1.select 
)

雖然調(diào)用的時候挺漂亮的,但是有點繞。。。

眼雜 回答

事實上,JS的所有數(shù)據(jù)都是 double 型的,也就是64位浮點型,并按照IEEE754標(biāo)準(zhǔn)進(jìn)行保存。

但是在做位運算的時候要對兩個數(shù)進(jìn)行 toInt32 進(jìn)行類型轉(zhuǎn)換(>>>toUint32), 然后按照32位整型的bits 進(jìn)行位運算,運算結(jié)果也是按照Int32或是Uint32 進(jìn)行解釋,再轉(zhuǎn)換成double

function toUint32(x) { return x>>>0;}
function toInt32(x) { return x>>0;}

toUint32(-1); // 4294967295 === 2^32 - 1
toInt32(-1); // -1
toInt32(1.21); // 1

具體可一參考 ES標(biāo)準(zhǔn):http://www.ecma-international...

心夠野 回答

call是改變identify的this指向,具體指到誰,還要看你的sayHello方法是怎么被調(diào)用,被誰調(diào)用的,調(diào)用的時候用沒用call、apply方法。

骨殘心 回答

寫一個閉包變量儲存menu狀態(tài)

 let handler (function (){
  var isSlidedown = false
  return {
          isSlidedown = ! isSlidedown

//業(yè)務(wù)寫這里

  }
})();

btn.addEventListener('click', handler)