pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <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="2i020q0" 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="yiy2yic" 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的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  版本:

                  • react-router-dom 4.1.1
                  • react-router-redux 5.0.0-alpha.4
                  • 反應傳單 1.1.3
                  • 傳單 1.0.3

                  重現步驟

                  我創建了一張傳單地圖.我在其中添加了一些標記.這些標記有彈出窗口.在每個彈出窗口中,我都希望有一個 <Link>

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

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

                  <應用容器/><ConnectedRouter 歷史={歷史}>

                  <菜單容器/><開關><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}/></開關></div></連接路由器></div></提供者>,document.getElementById('root'))

                  預期行為

                  當彈出窗口打開時,我可以看到我的鏈接并點擊它.

                  實際行為

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

                  額外細節

                  在我的 <MapMode> 中,我使用傳單中的 <Map>.如果我在 <Map> 標簽上方設置一個 <Link> ,它就可以工作.只要我想在我的 <Map> 中有一個鏈接,它就會以某種方式中斷.這是我頁面的 React 結構,<Popup> 標簽只包含 null,因為 Javascript 正在破壞:

                  這是一個相當復雜的問題,所以請隨時向我提問.謝謝.

                  解決方案

                  我不能 100% 確定這個答案.但無論如何我都會嘗試,因為我認為至少它可能會為將來嘗試解決此問題的任何人提供一些啟示.

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

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

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

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

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

                  類 MapMaker 擴展 React.Component {//......//這確保你有路由器 this.context//您還可以添加需要傳遞到 Popup 的任何其他上下文靜態上下文類型 = {路由器: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
                      );
                    }
                  
                  }
                  

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

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

                  相關文檔推薦

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

                    <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="q20igmy" id='eAGwQ'><tfoot id='eAGwQ'></tfoot><dl id='eAGwQ'><fieldset id='eAGwQ'></fieldset></dl></div>

                            主站蜘蛛池模板: WTB5光栅尺-JIE WILL磁栅尺-B60数显表-常州中崴机电科技有限公司 | BESWICK球阀,BESWICK接头,BURKERT膜片阀,美国SEL继电器-东莞市广联自动化科技有限公司 | 深圳天际源广告-形象堆头,企业文化墙,喷绘,门头招牌设计制作专家 | 医院专用门厂家报价-医用病房门尺寸大全-抗菌木门品牌推荐 | 河南中整光饰机械有限公司-抛光机,去毛刺抛光机,精密镜面抛光机,全自动抛光机械设备 | 沈阳真空机_沈阳真空包装机_沈阳大米真空包装机-沈阳海鹞真空包装机械有限公司 | 【连江县榕彩涂料有限公司】官方网站 | 本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司 | 蒸压釜-陶粒板隔墙板蒸压釜-山东鑫泰鑫智能装备有限公司 | POS机办理_个人POS机免费领取 - 银联POS机申请首页 | 橡胶粉碎机_橡胶磨粉机_轮胎粉碎机_轮胎磨粉机-河南鼎聚重工机械制造有限公司 | 杜甫仪器官网|实验室平行反应器|升降水浴锅|台式低温循环泵 | 连栋温室大棚建造厂家-智能玻璃温室-薄膜温室_青州市亿诚农业科技 | crm客户关系管理系统,销售管理系统,crm系统,在线crm,移动crm系统 - 爱客crm | 今日热点_实时热点_奇闻异事_趣闻趣事_灵异事件 - 奇闻事件 | 炭黑吸油计_测试仪,单颗粒子硬度仪_ASTM标准炭黑自销-上海贺纳斯仪器仪表有限公司(HITEC中国办事处) | 紧急切断阀_气动切断阀_不锈钢阀门_截止阀_球阀_蝶阀_闸阀-上海上兆阀门制造有限公司 | 金环宇|金环宇电线|金环宇电缆|金环宇电线电缆|深圳市金环宇电线电缆有限公司|金环宇电缆集团 | 螺旋丝杆升降机-SWL蜗轮-滚珠丝杆升降机厂家-山东明泰传动机械有限公司 | 呼末二氧化碳|ETCO2模块采样管_气体干燥管_气体过滤器-湖南纳雄医疗器械有限公司 | 「阿尔法设计官网」工业设计_产品设计_产品外观设计 深圳工业设计公司 | 恒压供水控制柜|无负压|一体化泵站控制柜|PLC远程调试|MCGS触摸屏|自动控制方案-联致自控设备 | 知名电动蝶阀,电动球阀,气动蝶阀,气动球阀生产厂家|价格透明-【固菲阀门官网】 | 月嫂_保姆_育婴_催乳_母婴护理_产后康复_养老护理-吉祥到家家政 硫酸亚铁-聚合硫酸铁-除氟除磷剂-复合碳源-污水处理药剂厂家—长隆科技 | LHH药品稳定性试验箱-BPS系列恒温恒湿箱-意大利超低温冰箱-上海一恒科学仪器有限公司 | wika威卡压力表-wika压力变送器-德国wika代理-威卡总代-北京博朗宁科技 | 南京和瑞包装有限公司 | 开云(中国)Kaiyun·官方网站-登录入口 | 细沙回收机-尾矿干排脱水筛设备-泥石分离机-建筑垃圾分拣机厂家-青州冠诚重工机械有限公司 | 东莞海恒试验仪器设备有限公司 | 天津中都白癜风医院_天津白癜风医院_天津治疗白癜风 | 中山市派格家具有限公司【官网】 | 武汉EPS线条_EPS装饰线条_EPS构件_湖北博欧EPS线条厂家 | 广州展台特装搭建商|特装展位设计搭建|展会特装搭建|特装展台制作设计|展览特装公司 | 沧州友城管业有限公司-内外涂塑钢管-大口径螺旋钢管-涂塑螺旋管-保温钢管生产厂家 | 苏州同创电子有限公司 - 四探针测试仪源头厂家 | 成都茶楼装修公司 - 会所设计/KTV装修 - 成都朗煜装饰公司 | 减速机电机一体机_带电机减速器一套_德国BOSERL电动机与减速箱生产厂家 | 纸箱抗压机,拉力机,脂肪测定仪,定氮仪-山东德瑞克仪器有限公司 | 翰香原枣子坊加盟费多少钱-正宗枣核糕配方培训利润高飘香 | 聚合甘油__盐城市飞龙油脂有限公司 |