久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='XXYLE'></bdo><ul id='XXYLE'></ul>

      <legend id='XXYLE'><style id='XXYLE'><dir id='XXYLE'><q id='XXYLE'></q></dir></style></legend>
    1. <small id='XXYLE'></small><noframes id='XXYLE'>

      1. <tfoot id='XXYLE'></tfoot>

        <i id='XXYLE'><tr id='XXYLE'><dt id='XXYLE'><q id='XXYLE'><span id='XXYLE'><b id='XXYLE'><form id='XXYLE'><ins id='XXYLE'></ins><ul id='XXYLE'></ul><sub id='XXYLE'></sub></form><legend id='XXYLE'></legend><bdo id='XXYLE'><pre id='XXYLE'><center id='XXYLE'></center></pre></bdo></b><th id='XXYLE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XXYLE'><tfoot id='XXYLE'></tfoot><dl id='XXYLE'><fieldset id='XXYLE'></fieldset></dl></div>

        React Router Link 不適用于 LeafletJS

        React Router Link doesn#39;t work with LeafletJS(React Router Link 不適用于 LeafletJS)

        <tfoot id='1RDyQ'></tfoot>
        • <bdo id='1RDyQ'></bdo><ul id='1RDyQ'></ul>
          • <small id='1RDyQ'></small><noframes id='1RDyQ'>

                <i id='1RDyQ'><tr id='1RDyQ'><dt id='1RDyQ'><q id='1RDyQ'><span id='1RDyQ'><b id='1RDyQ'><form id='1RDyQ'><ins id='1RDyQ'></ins><ul id='1RDyQ'></ul><sub id='1RDyQ'></sub></form><legend id='1RDyQ'></legend><bdo id='1RDyQ'><pre id='1RDyQ'><center id='1RDyQ'></center></pre></bdo></b><th id='1RDyQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1RDyQ'><tfoot id='1RDyQ'></tfoot><dl id='1RDyQ'><fieldset id='1RDyQ'></fieldset></dl></div>
                    <tbody id='1RDyQ'></tbody>
                  <legend id='1RDyQ'><style id='1RDyQ'><dir id='1RDyQ'><q id='1RDyQ'></q></dir></style></legend>

                • 本文介紹了React Router Link 不適用于 LeafletJS的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  版本:

                  • react-router-dom 4.1.1
                  • react-router-redux 5.0.0-alpha.4
                  • 反應(yīng)傳單 1.1.3
                  • 傳單 1.0.3

                  重現(xiàn)步驟

                  我創(chuàng)建了一張傳單地圖.我在其中添加了一些標(biāo)記.這些標(biāo)記有彈出窗口.在每個(gè)彈出窗口中,我都希望有一個(gè) <Link>

                  如果有幫助,這是我的路由配置:

                  ReactDOM.render(<提供者商店={商店}>

                  <應(yīng)用容器/><ConnectedRouter 歷史={歷史}>

                  <菜單容器/><開關(guān)><Route path='/:area/:sport/list' 組件={ListContainer}/><路線路徑='/:area/:sport/map' 組件={MapContainer}/><Route path='/:area/:sport/rasp' 組件={RaspContainer}/><Route path='/:shortcode/details' 組件={StationDetailsContainer}/><從='/' 重定向到='/wellington/paragliding/list'/><路由組件={NoMatch}/></開關(guān)></div></連接路由器></div></提供者>,document.getElementById('root'))

                  預(yù)期行為

                  當(dāng)彈出窗口打開時(shí),我可以看到我的鏈接并點(diǎn)擊它.

                  實(shí)際行為

                  無法看到鏈接.它沒有生成.

                  額外細(xì)節(jié)

                  在我的 <MapMode> 中,我使用傳單中的 <Map>.如果我在 <Map> 標(biāo)簽上方設(shè)置一個(gè) <Link> ,它就可以工作.只要我想在我的 <Map> 中有一個(gè)鏈接,它就會以某種方式中斷.這是我頁面的 React 結(jié)構(gòu),<Popup> 標(biāo)簽只包含 null,因?yàn)?Javascript 正在破壞:

                  這是一個(gè)相當(dāng)復(fù)雜的問題,所以請隨時(shí)向我提問.謝謝.

                  解決方案

                  我不能 100% 確定這個(gè)答案.但無論如何我都會嘗試,因?yàn)槲艺J(rèn)為至少它可能會為將來嘗試解決此問題的任何人提供一些啟示.

                  我從 react 中的 this issue 得到了第一個(gè)提示-leaflet GitHub 存儲庫.根據(jù)那個(gè)和你的錯(cuò)誤,問題似乎是 Popup 無法從 context 訪問 router 因?yàn)?context 沒有傳入以他們呈現(xiàn)的方式彈出窗口.因此,如果我們可以將上下文顯式傳遞給 Popup,我們應(yīng)該能夠解決問題.

                  然后我找到了一種將上下文顯式傳遞到組件中的方法 this StackOverflow 答案.有了這個(gè),我認(rèn)為你應(yīng)該能夠使用如下的 HoC(高階組件)來解決你的問題.

                  這是向組件注入上下文的 HoC:

                  function withContext(WrappedComponent, context){類 ContextProvider 擴(kuò)展 React.Component {getChildContext() {返回上下文;}使成為() {返回 <WrappedComponent {...this.props}/>}}ContextProvider.childContextTypes = {};Object.keys(context).forEach(key => {ContextProvider.childContextTypes[key] = React.PropTypes.any.isRequired;});返回上下文提供者;}

                  假設(shè)您在一個(gè)名為 MapMaker 的組件中使用 Popup.然后你可以像這樣使用 HoC 將帶有 router 的上下文注入到 Popup 中.

                  類 MapMaker 擴(kuò)展 React.Component {//......//這確保你有路由器 this.context//您還可以添加需要傳遞到 Popup 的任何其他上下文靜態(tài)上下文類型 = {路由器:React.PropTypes.object.isRequired}使成為(){const PopupWithContext = withContext(Popup, this.context);返回 (//..... 你的 JSX 在 Popup 之前<PopupWithContext/>//用你的道具//.....彈出后你的JSX);}}

                  Versions:

                  • react-router-dom 4.1.1
                  • react-router-redux 5.0.0-alpha.4
                  • react-leaflet 1.1.3
                  • leaflet 1.0.3

                  Steps to reproduce

                  I create a leaflet map. In which I add some markers. These markers have popups. In each of these popup I want to have a <Link>

                  Also if it helps this is my Routing config:

                  ReactDOM.render(
                    <Provider store={store}>
                      <div>
                        <AppContainer />
                        <ConnectedRouter history={history}>
                          <div>
                            <MenuContainer />
                            <Switch>
                              <Route path='/:area/:sport/list' component={ListContainer} />
                              <Route path='/:area/:sport/map' component={MapContainer} />
                              <Route path='/:area/:sport/rasp' component={RaspContainer} />
                              <Route path='/:shortcode/details' component={StationDetailsContainer} />
                              <Redirect exact from='/' to='/wellington/paragliding/list' />
                              <Route component={NoMatch} />
                            </Switch>
                          </div>
                        </ConnectedRouter>
                      </div>
                    </Provider>,
                    document.getElementById('root')
                  )
                  

                  Expected Behavior

                  I can see my link and click on it when popup opens.

                  Actual Behavior

                  Impossible to see the link. It's not generated.

                  Extra details

                  Inside my <MapMode> I use <Map> from leaflet. If I set a <Link> just above the <Map> tag it works. As soon as I want to have a link inside my <Map>, somehow it breaks. This is the React structure of my page, <Popup> tag just contains null as Javascript is breaking:

                  It's quite a complex problem so feel free to ask me questions. Thanks.

                  解決方案

                  I'm not 100% sure about this answer. But anyway I'm going to try because I think at least it might shed some light to anyone who will try to solve this problem in future.

                  I got the first hint from this issue in react-leaflet GitHub repo. According to that and your error, it seems the problem is Popup can't access the router from the context because context isn't passed into the Popup with the way they render it. So we should be able to fix the problem if we can explicitly pass the context to Popup.

                  Then I found a way to explicitly pass the context into a component in this StackOverflow answer. With that, I think you should be able to use a HoC(Higher order Component) as follows to solve your problem.

                  This is the HoC that inject context to a component:

                  function withContext(WrappedComponent, context){
                  
                    class ContextProvider extends React.Component {
                      getChildContext() {
                        return context;
                      }
                  
                      render() {
                        return <WrappedComponent {...this.props} />
                      }
                    }
                  
                    ContextProvider.childContextTypes = {};
                    Object.keys(context).forEach(key => {
                      ContextProvider.childContextTypes[key] = React.PropTypes.any.isRequired; 
                    });
                  
                    return ContextProvider;
                  }
                  

                  Let's say you are using Popup inside a component called MapMaker. Then you can inject the context with router into Popup using the HoC like this.

                  class MapMaker extends React.Component {
                  
                    //......
                  
                    // This make sure you have router in you this.context
                    // Also you can add any other context that you need to pass into Popup
                    static contextTypes = {
                      router: React.PropTypes.object.isRequired
                    }
                  
                    render(){
                  
                      const PopupWithContext = withContext(Popup, this.context);
                  
                      return (
                        //..... your JSX before Popup
                        <PopupWithContext/> // with your props
                        //..... your JSX after Popup
                      );
                    }
                  
                  }
                  

                  這篇關(guān)于React Router Link 不適用于 LeafletJS的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個(gè)多邊形點(diǎn)是否在傳單中的另一個(gè)內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標(biāo)記群集圖標(biāo)顏色,繼承其余默認(rèn) CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點(diǎn)擊傳單標(biāo)記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認(rèn)加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)

                    <small id='eAGwQ'></small><noframes id='eAGwQ'>

                  • <legend id='eAGwQ'><style id='eAGwQ'><dir id='eAGwQ'><q id='eAGwQ'></q></dir></style></legend>

                          <tbody id='eAGwQ'></tbody>
                          <bdo id='eAGwQ'></bdo><ul id='eAGwQ'></ul>
                          <tfoot id='eAGwQ'></tfoot>

                        • <i id='eAGwQ'><tr id='eAGwQ'><dt id='eAGwQ'><q id='eAGwQ'><span id='eAGwQ'><b id='eAGwQ'><form id='eAGwQ'><ins id='eAGwQ'></ins><ul id='eAGwQ'></ul><sub id='eAGwQ'></sub></form><legend id='eAGwQ'></legend><bdo id='eAGwQ'><pre id='eAGwQ'><center id='eAGwQ'></center></pre></bdo></b><th id='eAGwQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eAGwQ'><tfoot id='eAGwQ'></tfoot><dl id='eAGwQ'><fieldset id='eAGwQ'></fieldset></dl></div>

                            主站蜘蛛池模板: 成人激情视频免费在线观看 | 欧美日韩在线观看一区 | 亚洲一区 | 日韩a v在线免费观看 | 久久久久久久久一区 | 亚洲精品自拍 | 国产精品一区二区三区免费观看 | 久久精品二区亚洲w码 | 爱草在线| 国产精品美女一区二区三区 | 欧美精品91 | 日韩中文一区二区 | av手机免费在线观看 | 亚洲精品一区二区三区四区高清 | 污书屋| 日日摸日日碰夜夜爽亚洲精品蜜乳 | 国产精品久久久久久久久久久久久 | 天天干人人| 亚洲精品乱码8久久久久久日本 | 久久av网站 | 国产精品中文字幕在线观看 | 色婷婷狠狠 | 作爱视频免费看 | 成人免费网站 | 黑色丝袜三级在线播放 | 一二区电影| 日本在线看片 | www.国产一区| 日本a视频 | 午夜av毛片 | 亚洲精品乱码久久久久v最新版 | 日日爱夜夜操 | av中文字幕网站 | 久久国产视频播放 | 宅男噜噜噜66一区二区 | 视频一区在线播放 | 91欧美激情一区二区三区成人 | 国产乱码精品1区2区3区 | 国产福利免费视频 | 欧美激情国产精品 | av手机在线看 |