<noframes id="hvfzz">

<noframes id="hvfzz"><form id="hvfzz"><th id="hvfzz"></th></form>

        <address id="hvfzz"><th id="hvfzz"><th id="hvfzz"></th></th></address><address id="hvfzz"><address id="hvfzz"></address></address>

        鍍金池/ 問答/HTML5  PHP  HTML/ 在react里面的constructor里面初始化觸發一個link+router

        在react里面的constructor里面初始化觸發一個link+router。

        就是在constructor里面觸發link,本來render里面已經設置好一個link+router,本來打開界面點擊link處,才顯示route設置好組件的內容,現在想在constructor里面觸發一下link,一打開界面就直接連同route里面設置的組件顯示出來。

        回答
        編輯回答
        冷咖啡

        不要在constructor中做

        2017年8月31日 06:57
        編輯回答
        淡墨

        已解決,constructor里面 setTimeout的function里面找到link的結點,用click()模擬一次點擊事件。具體代碼仿照:setTimeout(function() {

        // IE
        if(document.all) {
            document.getElementById("clickMe").click();
        }
        // 其它瀏覽器
        else {
            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            document.getElementById搜索("clickMe").dispatchEvent(e);
        }

        }, 2000);

        2017年2月28日 06:24