在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/ HTML問答
柚稚 回答
  1. Object.assign 不需要 babel-polyfill
  2. babel 是可以做到。 但問題是, 你是否需要轉(zhuǎn)化呢? 如果你的目標(biāo)瀏覽器就是最新瀏覽器就好了,它是不是就沒有必要轉(zhuǎn)化了?
喵小咪 回答

clipboard.png

 "1.粒粒皆辛苦,是的房間散發(fā)甲方的。2. 粒粒皆辛苦,是的房間散發(fā)甲方的。
3. 粒粒皆辛苦,是的房間散發(fā)甲方的。4. 粒粒皆辛苦,是的房間散發(fā)甲方的。"
.split(/\d+\./).map(function(str){ return str.replace(/(^\s*)|(\s*$)/g, ""); })

再把空串去掉就行了.
拮據(jù) 回答
datas.reduce(function(pre, next) {
    return pre + next.age;
}, 0);
萌面人 回答

增加兩個標(biāo)記,用來標(biāo)記你單擊的時候,初始狀態(tài)

var now = [], start = [], scale = 1, rotation = 0 , sPageX = 0, sPageY = 0;
改為
var now = [], start = [], scale = 1, rotation = 0 , sPageX = 0, sPageY = 0,
    oldScale = 0,
    oldRotation = 0;
    

touchstart里面

oldScale  = _this.scale.toFixed(2);
oldRotation  = _this.rotation.toFixed(2);

touchmove里面的時候,把old那個縮放加上

離夢 回答

token可以放到cookie發(fā)給后臺啊,后臺能拿到cookie中的token字段,畢竟前端請求也是這么傳過去的

clipboard.png

   var div = document.getElementById('div');
        div.onclick = () => {
            let headres = {
                method: 'post',
                credentials: 'include',
                headers: {
                    'token': '11111'
                },
                body: ''
            }
            fetch('/token', headres).then(x => x.json()).then(x => {
                console.log(x);
            }).catch(err => {
                console.error(err);
            })
        }

我使用你的發(fā)送方式

    let xhr = new XMLHttpRequest();
            xhr.onreadystatechange = function () {    //響應(yīng)完成后的回調(diào)函數(shù)
                if (xhr.readyState == 4) {            //如果響應(yīng)完成...此時還不知是否響應(yīng)成功
                    if (xhr.status == 200) {        //如果響應(yīng)成功
                        console.log(xhr.responseText);    //使用返回的數(shù)據(jù)responseText
                    } else {
                        console.log(xhr.responseText);
                    }
                }
            };
            xhr.open("POST", '/token');    //準(zhǔn)備請求, 但不發(fā)送. 使用get方法, 獲取a.html

            xhr.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');
            xhr.setRequestHeader('token', '3333');

            xhr.send(222);

clipboard.png

北城荒 回答

map的返回值是一個數(shù)組,這個問題用forEach比較合適

let newArr = [];
arr01.forEach(a1 => {
    arr02.forEach(a2 => {
        newArr.push({
            account: a1.account,
            city: a2.city
        });
    });
});
擱淺 回答

兄弟 你不同的二級域名不就只用了一個頂級域名嗎

萌二代 回答
  1. 為啥你要寫 node 后端?現(xiàn)有的 Java 無法滿足需求么?
  2. webpack 基于 node 環(huán)境運行,但它只是個打包工具,生產(chǎn)環(huán)境基本上用不到。這個都沒理解,我覺得你需要好好跟領(lǐng)導(dǎo)聊聊……
  3. node.js 的目標(biāo)是把 JS 帶到全平臺。對于前端開發(fā)者來說,它帶來的第一個巨大利好,就是我們可以用它完善一整套前端工具體系,所以你可以看到很多類似 webpack 的工具。這并不影響用它跑服務(wù)。

data事件是flow模式才會觸發(fā)的,而事件機制是node內(nèi)部維護(hù)的,所以名稱也是內(nèi)部規(guī)定的。

墨沫 回答

https://github.com/chenyinkai...

可以參考一下,沒有辦法直接判斷是否下載了app

熟稔 回答

沒記錯的話android P所有隱藏方法已經(jīng)不允許開發(fā)者通過任何形式進(jìn)行調(diào)用了吧,反射都不行。

柚稚 回答

main 是個靜態(tài)方法啊,怎么引用一個 非 static 的屬性 UserService。

public class SpringMyBatisTest {
    
    @Autowired
    private UserService userService;
    
    public staic void main(String ... args) {
        new SpringMyBatisTest().test();
    }
    
    public void test() {
        User user = userService.getUserByUsername("abc");
        ...
    }
}
伐木累 回答

ref拿到實例,然后調(diào)用實例的blur方法試一下,或者用findDOMNode拿到Input的dom節(jié)點然后調(diào)用blur方法。

鐧簞噯 回答

為什么要增大兩倍呢? weex打包到web平臺會自動計算成對應(yīng)的寬度吧..

刮刮樂 回答

去網(wǎng)上找找插件,IE低版本不支持border-radius(包括其它CSS3屬性)

這類問題直接去網(wǎng)上搜索比在這兒提問好且快

貓小柒 回答

this.$route.query.參數(shù)名字

遺莣 回答

如何正確地在React中處理事件

參考官網(wǎng)

1、構(gòu)造器內(nèi)綁定this

class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            count: 0
        };
        this.handleClick = this.handleClick.bind(this);
    }

    handleClick() {
        this.setState({
            count: ++this.state.count
        });
    }

    render() {
        return (
        <div>
            <div>{this.state.count}</div>
            <button onClick={this.handleClick}>Click</button>
        </div>
        );
    }
}

這種方式的好處是每次render,不會重新創(chuàng)建一個回調(diào)函數(shù),沒有額外的性能損失。需要注意的是,使用這種方式要在構(gòu)造函數(shù)中為事件回調(diào)函數(shù)綁定this: this.handleClick = this.handleClick.bind(this),否則handleClick中的this是undefined。這是因為ES6 語法的緣故,ES6 的 Class 構(gòu)造出來的對象上的方法默認(rèn)不綁定到 this 上,需要我們手動綁定。

2、屬性初始化

使用ES7的 property initializers,代碼可以這樣寫:

class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            count: 0
        };
    }

    handleClick = () => {
        this.setState({
            count: ++this.state.count
        });
    }

    render() {
        return (
        <div>
            <div>{this.state.count}</div>
            <button onClick={this.handleClick}>Click</button>
        </div>
        );
    }
}

這種方式就不需要手動綁定this了。但是你需要知道,這個特性還處于試驗階段,默認(rèn)是不支持的。如果你是使用官方腳手架Create React App 創(chuàng)建的應(yīng)用,那么這個特性是默認(rèn)支持的。你也可以自行在項目中引入babel的transform-class-properties插件獲取這個特性支持。

3、箭頭函數(shù)

class MyComponent extends React.Component {
    render() {
        return (
        <button onClick={()=>{console.log('button clicked');}}>
            Click
        </button>
        );
    }
}

當(dāng)事件響應(yīng)邏輯比較復(fù)雜時,如果再把所有的邏輯直接寫在onClick的大括號內(nèi),就會導(dǎo)致render函數(shù)變得臃腫,不容易直觀地看出組件render出的元素結(jié)構(gòu)。這時,可以把邏輯封裝成組件的一個方法,然后在箭頭函數(shù)中調(diào)用這個方法。如下所示:

class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            count: 0
        };
    }
    handleClick() {
        this.setState({
            count: ++this.state.count
        });
    }
    render() {
        return (
        <div>
            <div>{this.state.number}</div>
            <button onClick={()=>{this.handleClick();}}>Click</button>
        </div>
        );
    }
}

這種方式最大的問題是,每次render調(diào)用時,都會重新創(chuàng)建一個事件的回調(diào)函數(shù),帶來額外的性能開銷,當(dāng)組件的層級越低時,這種開銷就越大,因為任何一個上層組件的變化都可能會觸發(fā)這個組件的render方法。當(dāng)然,在大多數(shù)情況下,這點性能損失是可以不必在意的。這種方式也有一個好處,就是不需要考慮this的指向問題,因為這種寫法保證箭頭函數(shù)中的this指向的總是當(dāng)前組件。

4、函數(shù)傳遞參數(shù)

事件的回調(diào)函數(shù)默認(rèn)是會被傳入一個事件對象Event作為參數(shù)的。如果我想傳入其他參數(shù)給回調(diào)函數(shù)應(yīng)該怎么辦呢?

使用第一種方式(構(gòu)造器內(nèi)綁定this)的話,可以把綁定this的操作延遲到render中,在綁定this的同時,綁定額外的參數(shù):

// 代碼6
class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
        list: [1,2,3,4],
        current: 1
        };
    }

    handleClick(item) {
        this.setState({
            current: item
        });
    }

    render() {
        return (
        <ul>
            {this.state.list.map(
                (item)=>(
                <li className={this.state.current === item ? 'current':''} 
                onClick={this.handleClick.bind(this, item)}>{item}
                </li>
                )
            )}
        </ul>
        );
    }
}

使用第二種方式(屬性初始化),解決方案和第一種基本一致:

// 代碼7
class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            list: [1,2,3,4],
            current: 1
        };
    }

    handleClick = (item) =>  {
        this.setState({
            current: item
        });
    }

    render() {
        return (
        <ul>
            {this.state.list.map(
                (item)=>(
                <li className={this.state.current === item ? 'current':''} 
                onClick={this.handleClick.bind(undefined, item)}>{item}
                </li>
                )
            )}
        </ul>
        );
    }
}

不過這種方式就有點雞肋了,因為雖然你不需要通過bind函數(shù)綁定this,但仍然要使用bind函數(shù)來綁定其他參數(shù)。

使用第三種方式(函數(shù)傳遞參數(shù))的話很簡單,直接傳就可以了:

class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            list: [1,2,3,4],
            current: 1
        };
    }

    handleClick(item,event) {
        this.setState({
            current: item
        });
    }

    render() {
        return (
        <ul>
            {this.state.list.map(
                (item)=>(
                <li className={this.state.current === item ? 'current':''} 
                onClick={(event) => this.handleClick(item, event)}>{item}
                </li>
                )
            )}
        </ul>
        );
    }
}

關(guān)于事件響應(yīng)的回調(diào)函數(shù),還有一個地方需要注意。不管你在回調(diào)函數(shù)中有沒有顯式的聲明事件參數(shù)Event,React都會把事件Event作為參數(shù)傳遞給回調(diào)函數(shù),且參數(shù)Event的位置總是在其他自定義參數(shù)的后面。例如,在代碼6和代碼7中,handleClick的參數(shù)中雖然沒有聲明Event參數(shù),但你依然可以通過arguments[1]獲取到事件Event對象。

總結(jié)一下,三種綁定事件回調(diào)的方式,第一種有額外的性能損失;第二種需要手動綁定this,代碼量增多;第三種用到了ES7的特性,目前并非默認(rèn)支持,需要Babel插件的支持,但是寫法最為簡潔,也不需要手動綁定this。推薦使用第二種和第三種方式。