創(chuàng)建一個(gè) object URL, 然后將其設(shè)置為video標(biāo)簽src屬性的值:
var URL = window.URL || window.webkitURL
videoNode.src = URL.createObjectURL(file)問(wèn)題描述的不夠清晰啊,32->16 16->16 冪等?
你直接將txt的代碼復(fù)制出來(lái)、
在vs新建一個(gè)cs文件,將代碼復(fù)制進(jìn)去,編譯不就行了、
建議在flvjs.isSupported()后接個(gè)判斷 看看是否機(jī)器不支持
if(flvjs.isSupported()){
//balabala
}else{
alert("this phone is not support")
}var total = [0,1,2,3,4].reduce((a, b)=>a + b); //10
reduce接受一個(gè)函數(shù),函數(shù)有四個(gè)參數(shù),分別是:
我們還是以上面那個(gè)數(shù)組為例,把這幾個(gè)參數(shù)打印出來(lái)看看:
[0, 1, 2, 3,4].reduce(function(previousValue, currentValue, index, array){
return previousValue + currentValue;
});
reduce 還可以扁平化一個(gè)二維數(shù)組
var flattened = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) {
return a.concat(b);
}, []);
// flattened == [0, 1, 2, 3, 4, 5]
splice()
方法向/從數(shù)組中添加/刪除項(xiàng)目,然后返回被刪除的項(xiàng)目
[1,2,3,4,5].splice(2,0,9);
//[1,2,9,3,4,5]
[1,2,3,4,5].splice(2,2,9);
//[1,2,9,5]
在現(xiàn)有數(shù)組后面追加數(shù)組,并返回新數(shù)組,不影響現(xiàn)有數(shù)組。
var arra = [1,2,3];
var arrb = [4,5,6];
var arrc = arra.concat(arrb);
//[1, 2, 3, 4, 5, 6]
用指定間隔符連起來(lái),把數(shù)組轉(zhuǎn)為字符串。
var arrstr = ['a','b','c','d','e','f','g'];
arrstr.join("*");
///"a*b*c*d*e*f*g"
但需要注意的是只轉(zhuǎn)換一維數(shù)組里面,如果數(shù)組里面還有數(shù)組,將不是采用join指定的字符串接,而是采用默認(rèn)的toString();
var a = ['a','b','c','d','e','f','g',[11,22,33]];
a.join("*");
// -> a * b * c * d * e * f * g * 11,22,33
var a = ["aa","bb","cc"];
a.pop(); //cc
var a = ["aa","bb","cc"];
a.shift();
// -> aa
a
// -> bb,cc
==注:當(dāng)數(shù)組為空時(shí),返回undefined==
var a = ["aa","bb","cc"];
a.unshift();
//4 注:IE下返回undefined
var a = [11,2,3,33445,5654,654,"asd","b"];
a.sort() // -> 11,2,3,33445,5654,654,asd,b
var a = [11,3,5,66,4];
a.reverse();
// -> 4,66,5,3,11
==如果數(shù)組里面還包含數(shù)組,則當(dāng)為對(duì)象處理,并不會(huì)把元素解出來(lái)==
var a = ['a','b','c','d','e','f','g',[4,11,33]];
a.reverse();
// -> 4,11,33,g,f,e,d,c,b,a
a.join(" * ");
// -> 4,11,33 * g * f * e * d * c * b * a
var a = ['a','b','c','d','e','f','g'];
alert(a.slice(1,2)); // -> b
alert(a.slice(2)); // -> c,d,e,f,g
alert(a.slice(-4)); // -> d,e,f,g
alert(a.slice(-2,-6)); // -> 空
var a = [1,2,3,4,5,6,7,8,9];
document.write(a.splice(3,2)); // -> 4,5
document.write(a); // -> 1,2,3,6,7,8,9
document.write(a.splice(4)); // -> 7,8,9 注:IE下返回空
document.write(a); // -> 1,2,3,6
document.write(a.splice(0,1)); // -> 1
document.write(a); // -> 2,3,6
document.write(a.splice(1,1,["aa","bb","cc"])); // -> 3
document.write(a); // -> 2,aa,bb,cc,6,7,8,9
document.write(a.splice(1,2,"ee").join("#")); // -> aa,bb,cc#6
document.write(a); // -> 2,ee,7,8,9
document.write(a.splice(1,2,"cc","aa","tt").join("#")); // -> ee#7
document.write(a); // -> 2,cc,aa,tt,8,9
==注:注意該方法在IE下,第二個(gè)參數(shù)是必須的,不填則默認(rèn)為0,例如a.splice(4),在IE下則返回空,效果等同于a.splice(4,0)==
var a = [1,2,[3,4],5];
a.toString();
//1,2,3,4,5
var b = 10;
b.toString(2);
// 1010 2進(jìn)制轉(zhuǎn)換
var a = [5,6,7,8,9,["A","BB"],100];
document.write(a.toString()); // -> 5,6,7,8,9,A,BB,100
var b = new Date()
document.write(b.toString()); // -> Sat Aug 8 17:08:32 UTC+0800 2009
var c = function(s){
alert(s);
}
document.write(c.toString()); // -> function(s){ alert(s); }
布爾值則返回true或false,對(duì)象則返回[object objectname]
相比join()方法,join()只對(duì)一維數(shù)組進(jìn)行替換,而toString()則把整個(gè)數(shù)組(不管一維還是多維)完全平面化
同時(shí)該方法可用于10進(jìn)制、2進(jìn)制、8進(jìn)制、16進(jìn)制轉(zhuǎn)換,例如:
var a = [5,6,7,8,9,"A","BB",100];
for(var i=0; i<a.length; i++){
document.write(a[i].toString() + " 的二進(jìn)制是 " + a[i].toString(2) + " ,八進(jìn)制是 " + a[i].toString(8) + " ,十六進(jìn)制是 " + a[i].toString(16)); // -> 4,5
}
/**
5 的二進(jìn)制是 101 ,八進(jìn)制是 5 ,十六進(jìn)制是 5
6 的二進(jìn)制是 110 ,八進(jìn)制是 6 ,十六進(jìn)制是 6
7 的二進(jìn)制是 111 ,八進(jìn)制是 7 ,十六進(jìn)制是 7
8 的二進(jìn)制是 1000 ,八進(jìn)制是 10 ,十六進(jìn)制是 8
9 的二進(jìn)制是 1001 ,八進(jìn)制是 11 ,十六進(jìn)制是 9
A 的二進(jìn)制是 A ,八進(jìn)制是 A ,十六進(jìn)制是 A
BB 的二進(jìn)制是 BB ,八進(jìn)制是 BB ,十六進(jìn)制是 BB
100 的二進(jìn)制是 1100100 ,八進(jìn)制是 144 ,十六進(jìn)制是 64
*/
==注:轉(zhuǎn)換只能在元素進(jìn)行,如果對(duì)整個(gè)數(shù)組進(jìn)行轉(zhuǎn)換,則原封不動(dòng)返回該數(shù)組==
var a = new Date();
document.write(a.toString()); // -> Sat Aug 8 17:28:36 UTC+0800 2009
document.write(a.toLocaleString()); // -> 2009年8月8日 17:28:36
document.write(a.toLocaleDateString()); // -> 2009年8月8日
區(qū)別在于,toString()返回標(biāo)準(zhǔn)格式,toLocaleString()返回本地格式完整日期(在【控制面板】>>【區(qū)域和語(yǔ)言選項(xiàng)】,通過(guò)修改[時(shí)間]和[長(zhǎng)日期]格式),toLocaleDateString()跟toLocaleString()一樣,只是少了時(shí)間
var a = [1,2,3,[4,5,6,[7,8,9]]];
var b = new Date();
var c = true;
var d = function(){
alert("sunnycat");
};
document.write(a.valueOf()); // -> 1,2,3,4,5,6,7,8,9
document.write(typeof (a.valueOf())); // -> object
document.write(b.valueOf()); // -> 1249874470052
document.write(typeof(b.valueOf())); // -> number
document.write(c.valueOf()); // -> true
document.write(typeof(c.valueOf())); // -> boolean
document.write(d.valueOf()); // -> function () { alert("sunnycat"); }
document.write(typeof(d.valueOf())); // -> function
數(shù)組也是對(duì)象,所以typeof (a.valueOf())返回object,返回的依然是個(gè)多維數(shù)組
var a = [1,2,3,[4,5,6,[7,8,9]]];
var aa = a.valueOf();
document.write(aa[3][3][1]); // -> 8
==注:Date對(duì)象返回的是距離1970年1月1日的毫秒數(shù),Math和Error對(duì)象沒(méi)有valueOf方法==
array.every(function(currentValue,index,arr), thisValue)
如果數(shù)組中檢測(cè)到有一個(gè)元素不滿(mǎn)足,則整個(gè)表達(dá)式返回 false ,且剩余的元素不會(huì)再進(jìn)行檢測(cè)。
如果所有元素都滿(mǎn)足條件,則返回 true。
var a = [1,2,3,4,5];
function checkAdult(num){
return num > 0
}
a.every(checkAdult);
//true
/**
array.every(function(currentValue,index,arr), thisValue)
currentValue 必須。當(dāng)前元素的值
index 可選。當(dāng)期元素的索引值
arr 可選。當(dāng)期元素屬于的數(shù)組對(duì)象
*/
filter() 方法創(chuàng)建一個(gè)新的數(shù)組,新數(shù)組中的元素是通過(guò)檢查指定數(shù)組中符合條件的所有元素。
ar ages = [32, 33, 16, 40];
function checkAdult(age) {
return age >= 18;
}
function myFunction() {
document.getElementById("demo").innerHTML = ages.filter(checkAdult);
}
//32,33,40
array.find(function(currentValue, index, arr),thisValue)
find() 方法返回傳入一個(gè)測(cè)試條件(函數(shù))符合條件的數(shù)組第一個(gè)元素。
find() 方法為數(shù)組中的每個(gè)元素都調(diào)用一次函數(shù)執(zhí)行:
當(dāng)數(shù)組中的元素在測(cè)試條件時(shí)返回 true 時(shí), find() 返回符合條件的元素,之后的值不會(huì)再調(diào)用執(zhí)行函數(shù)。
如果沒(méi)有符合條件的元素返回 undefined
var ages = [3, 10, 18, 20];
function checkAdult(age) {
return age >= 18;
}
function myFunction() {
document.getElementById("demo").innerHTML = ages.find(checkAdult);
}
//18
array.some(function(currentValue,index,arr),thisValue)
Array.prototype.includes方法返回一個(gè)布爾值,表示某個(gè)數(shù)組是否包含給定的值,與字符串的includes方法類(lèi)似。ES2016 引入了該方法。
// -1
[1, 2, 3].includes(2) // true
[1, 2, 3].includes(4) // false
[1, 2, NaN].includes(NaN) // true
下面代碼用來(lái)檢查當(dāng)前環(huán)境是否支持該方法,如果不支持,部署一個(gè)簡(jiǎn)易的替代版本。
const contains = (() =>
Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
)();
contains(['foo', 'bar'], 'baz'); // => false
另外,Map 和 Set 數(shù)據(jù)結(jié)構(gòu)有一個(gè)has方法,需要注意與includes區(qū)分。
array.fill(value, start, end)
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.fill("Runoob");
//Runoob,Runoob,Runoob,Runoob
ES6 提供三個(gè)新的方法——entries(),keys()和values()——用于遍歷數(shù)組。它們都返回一個(gè)遍歷器對(duì)象(詳見(jiàn)《Iterator》一章),可以用for...of循環(huán)進(jìn)行遍歷,唯一的區(qū)別是keys()是對(duì)鍵名的遍歷、values()是對(duì)鍵值的遍歷,entries()是對(duì)鍵值對(duì)的遍歷。
for (let index of ['a', 'b'].keys()) {
console.log(index);
}
// 0
// 1
for (let elem of ['a', 'b'].values()) {
console.log(elem);
}
// 'a'
// 'b'
for (let [index, elem] of ['a', 'b'].entries()) {
console.log(index, elem);
}
// 0 "a"
// 1 "b"
類(lèi)數(shù)組對(duì)象轉(zhuǎn)數(shù)組
let arrayLike = {
'0': 'a',
'1': 'b',
'2': 'c',
length: 3
};
// TypeError: Cannot spread non-iterable object.
let arr = [...arrayLike];
Array.of(3, 11, 8) // [3,11,8]
Array.of(3) // [3]
Array.of(3).length // 1
Array.of() // []
Array.of(undefined) // [undefined]
Array.of(1) // [1]
Array.of(1, 2) // [1, 2]
//模擬實(shí)現(xiàn)
function ArrayOf(){
return [].slice.call(arguments);
}可以在input[name="max"]輸入后blur時(shí)加個(gè)判斷,如果輸入小于input[name="min"]就清空或設(shè)定默認(rèn)值,提示用戶(hù)重新輸入。同理在input[name="min"]輸入后blur時(shí)加個(gè)判斷,如果輸入大于input[name="max"]時(shí)也清空或設(shè)定默認(rèn)值,提示用戶(hù)重新輸入。
ie8,不要用flex,不要用CSS3,不要用漸變背景……
基本只能按照上世紀(jì)float去寫(xiě)頁(yè)面吧。
這是一個(gè)react-native的腳手架工具,比官方的腳手架工具多了很多東西,可以快速創(chuàng)建react native的項(xiàng)目,同時(shí)包含了react-native的最佳實(shí)踐,能快速添加刪除插件
pyo 優(yōu)化:-O flag, optimized code is generated and stored in .pyo files. The optimizer currently doesn't help much; it only removes assert statements. When -O is used, all bytecode is optimized; .pyc files are ignored and .py files are compiled to optimized bytecode.-O flags to the Python interpreter (-OO) will cause the bytecode compiler to perform optimizations that could in some rare cases result in malfunctioning programs. Currently only __doc__ strings are removed from the bytecode, resulting in more compact .pyo files. Since some programs may rely on having these available, you should only use this option if you know what you're doing..pyc or .pyo file than when it is read from a .py file; the only thing that's faster about .pyc or .pyo files is the speed with which they are loaded..pyc or .pyo file. Thus, the startup time of a script may be reduced by moving most of its code to a module and having a small bootstrap script that imports that module. It is also possible to name a .pyc or .pyo file directly on the command line.pyd:pyd 可以理解為 Windows DLL 文件。
.pyd files are dll’s, but there are a few differences. If you have a DLL named foo.pyd, then it must have a function PyInit_foo(). You can then write Python "import foo", and Python will search for foo.pyd (as well as foo.py, foo.pyc) and if it finds it, will attempt to call PyInit_foo() to initialize it. You do not link your .exe with foo.lib, as that would cause Windows to require the DLL to be present.foo.pyd is PYTHONPATH, not the same as the path that Windows uses to search for foo.dll. Also, foo.pyd need not be present to run your program, whereas if you linked your program with a dll, the dll is required. Of course, foo.pyd is required if you want to say import foo. In a DLL, linkage is declared in the source code with __declspec(dllexport). In a .pyd, linkage is defined in a list of available functions.input不設(shè)置confirm-hold這個(gè)屬性輸入完成后可以收起輸入鍵盤(pán),或者在data里面給一個(gè) confirmHold: false,在input里面設(shè)置 confirm-hold="{{confirmHold}}"這樣也是可以的,直接寫(xiě)成confirm-hold="false"好像有點(diǎn)問(wèn)題的,confirm-hold接受Boolean類(lèi)型的參數(shù),直接寫(xiě)出這樣會(huì)把這個(gè)當(dāng)字符串.type是number時(shí),你可以綁定input輸入框,檢測(cè)到你想要的結(jié)果時(shí)直接調(diào)用wx.hideKeyboard()
是ELK吧?官方的文檔沒(méi)毛病啊我就是這么掛載的,我這里還新增了log的掛載。
- /elasticsearch/data:/usr/share/elasticsearch/data
- /elasticsearch/logs:/usr/share/elasticsearch/logs
另外可以參考docker-elk
首先看文檔的例子 https://reacttraining.com/rea...
然后是我自己寫(xiě)的
<div className="App">
<Router>
{/*<div>*/}
{/*<div>*/}
{/*<NavLink to='/' > one_ </NavLink>*/}
{/*<Link to='/page2' children='halo' />*/}
{/*</div>*/}
{/*<Route path='/' component={Page1} />*/}
{/*</div>*/}
<Route render={ ({location}) => (
<div style={{'position': 'absolute', 'top': 0}} >
<div>
<ul>
<li> <Link to='/page1' children='page1' /> </li>
<li> <Link to='/page2' children='page2' /> </li>
</ul>
</div>
<Route exact={true} to='/' render={ () => (
<Redirect to='/page1' />
) } />
<div style={{'position': 'absolute', 'top': '60px'}} >
<CSSTransitionGroup
transitionName="example"
transitionEnterTimeout={500}
transitionLeaveTimeout={500}
>
<Route
location={location}
key={location.key}
path='/:path'
component={getCom}
/>
</CSSTransitionGroup>
</div>
</div>
) } />
</Router>
</div>
我之前用的方法不可以, 是因?yàn)槟莻€(gè)Layout里面接受的this.props.children 是一個(gè)數(shù)組, 那個(gè)數(shù)組里面的兩個(gè)值就是 Page1 和Page2 的兩個(gè)組件 不管我怎么點(diǎn)擊切換那里面的children 都是那個(gè)數(shù)組, 不會(huì)改變, 那么key也就不會(huì)改變, 在動(dòng)畫(huà)組件里面的key不改變就意味著沒(méi)有動(dòng)畫(huà)發(fā)生。 因?yàn)樗强縦ey來(lái)識(shí)別不同的組件的。 然后是官網(wǎng)的方法。 關(guān)鍵的地方在于那個(gè) getCom的無(wú)狀態(tài)組件 通過(guò)當(dāng)前的pathname去 返回相應(yīng)的組件 然后的key也改變了 就有動(dòng)畫(huà)了。
以上是我的理解, 很粗糙, 希望大家指正mark關(guān)注一下問(wèn)題,沒(méi)有經(jīng)歷過(guò)這樣的項(xiàng)目,所以不清楚具體怎么解決的.
然后提一下自己的一些想法:
他們可能沒(méi)有緩存各種組合條件的查詢(xún)結(jié)果,我認(rèn)為商品單項(xiàng)是被緩存了,比如 "全聚德烤鴨","肯德基五折券" 這種具體單個(gè)商品是緩存了.但是各種條件組合的查詢(xún)結(jié)果應(yīng)該不會(huì)被緩存.
如果單品被緩存,那么只要能保證一個(gè)高效的多條件查詢(xún)引擎就可以了,查詢(xún)出來(lái)的結(jié)果就是各種商品的id,然后從緩存高速獲取到這些商品就ok了.這種高速的多面查詢(xún)引擎可以通過(guò)elasticsearch來(lái)實(shí)現(xiàn).
僅僅是個(gè)人想法 , 持續(xù)關(guān)注該問(wèn)題 , 希望看到合適的答案.
我倒是寫(xiě)過(guò)一個(gè)簡(jiǎn)單的:http://show.bestime.live/projects/js-demos/scroll.html
同是新手,沒(méi)有用過(guò)你說(shuō)的那個(gè)插件。但是多頁(yè)面的話(huà),直接指定多個(gè)entry,用html-webpack-plugin提取多個(gè)html文件都是可以的
1、如果你所有的變量都定義在最外層,也就是window環(huán)境下,你要想一想,如果程序變得越來(lái)越大,你一個(gè)不小心就把某一個(gè)變量修改了,bug很難定位
2、閉包簡(jiǎn)單來(lái)說(shuō),就是內(nèi)層函數(shù)能夠訪問(wèn)到作用域鏈上的變量。你的例子太簡(jiǎn)單了,如果單單只返回值,怎么返回都沒(méi)什么區(qū)別,但是如果你是暴露接口方法,使之能操作你函數(shù)里面的變量呢?這就又不一樣了,只返回值你永遠(yuǎn)不能在外層對(duì)這個(gè)變量進(jìn)行修改,相當(dāng)于把你的變量封裝了起來(lái),外層不能改變他,也就解決了1里的問(wèn)題
3、如2中所說(shuō),你可以
function func3 () {
var num = 1
function add () {
num++
}
function getNum () {
return num
}
return {
add: add,
getNum: getNum
}
}
var t = func3()
t.add()
t.getNum()
這樣是不是就封裝了一些操作了,也變得更加有意義呢?例子還是太簡(jiǎn)單,只是說(shuō)明對(duì)變量的封裝。
把這兩行放在前面:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=abc.xlsx");
然后再是下面兩行:
InputStream is = new FileInputStream("c:\\abc.xlsx");
org.apache.commons.io.IOUtils.copy(is, response.getOutputStream());
這樣就能正常下載文件了。
growing io 無(wú)代碼埋點(diǎn)
你這個(gè)的問(wèn)題不僅僅是匹配17091217297錯(cuò)誤,其實(shí)還有很多錯(cuò)誤的比如17097077297也會(huì)錯(cuò)誤,其實(shí)應(yīng)該寫(xiě)成這樣就好了String pattern = "^(?=\\d*(\\d)\\1\\1\\1\\d*$)1[35789]\\d{9}$";
其實(shí)還有一個(gè)笨辦法,就是把所有重復(fù)4個(gè)的都標(biāo)識(shí)出來(lái),比如:String pattern = "^(?=\\d*(0000|1111|2222|3333|4444|5555|6666|7777|8888|9999)\\d*)1[35789]\\d{9}$";
北大青鳥(niǎo)APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專(zhuān)業(yè)的國(guó)家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國(guó)家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國(guó)制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國(guó)職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開(kāi)發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_(kāi)發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開(kāi)發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開(kāi)發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開(kāi)發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問(wèn),美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。