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="zzxrr75" 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="55hj7p7" 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="rpvjnnl" id='eAGwQ'><tfoot id='eAGwQ'></tfoot><dl id='eAGwQ'><fieldset id='eAGwQ'></fieldset></dl></div>

                            主站蜘蛛池模板: DDoS安全防护官网-领先的DDoS安全防护服务商 | 不锈钢发酵罐_水果酒发酵罐_谷物发酵罐_山东誉诚不锈钢制品有限公司 | 依维柯自动挡房车,自行式国产改装房车,小型房车价格,中国十大房车品牌_南京拓锐斯特房车 - 南京拓锐斯特房车 | 立式壁挂广告机厂家-红外电容触摸一体机价格-华邦瀛 | 元拓建材集团官方网站 | 卫生纸复卷机|抽纸机|卫生纸加工设备|做卫生纸机器|小型卫生纸加工需要什么设备|卫生纸机器设备多少钱一台|许昌恒源纸品机械有限公司 | 硬齿面减速机[型号全],ZQ减速机-淄博久增机械 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 盛源真空泵|空压机-浙江盛源空压机制造有限公司-【盛源官网】 | 万烁建筑设计院-建筑设计公司加盟,设计院加盟分公司,市政设计加盟 | 冷藏车厂家|冷藏车价格|小型冷藏车|散装饲料车厂家|程力专用汽车股份有限公司销售十二分公司 | 纯水电导率测定仪-万用气体检测仪-低钠测定仪-米沃奇科技(北京)有限公司www.milwaukeeinst.cn 锂辉石检测仪器,水泥成分快速分析仪-湘潭宇科分析仪器有限公司 手术室净化装修-手术室净化工程公司-华锐手术室净化厂家 | 开平机_纵剪机厂家_开平机生产厂家|诚信互赢-泰安瑞烨精工机械制造有限公司 | 聚合氯化铝-碱式氯化铝-聚合硫酸铁-聚氯化铝铁生产厂家多少钱一吨-聚丙烯酰胺价格_河南浩博净水材料有限公司 | 南京欧陆电气股份有限公司-风力发电机官网 | PU树脂_水性聚氨酯树脂_聚氨酯固化剂_聚氨酯树脂厂家_宝景化工 | 工业制氮机_psa制氮机厂家-宏骁智能装备科技江苏有限公司 | 网站制作优化_网站SEO推广解决方案-无锡首宸信息科技公司 | 抖音短视频运营_企业网站建设_网络推广_全网自媒体营销-东莞市凌天信息科技有限公司 | 耐酸泵,耐酸泵厂家-淄博华舜耐腐蚀真空泵 | 立式_复合式_壁挂式智能化电伴热洗眼器-上海达傲洗眼器生产厂家 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 工业铝型材生产厂家_铝合金型材配件批发精加工定制厂商 - 上海岐易铝业 | 小型玉石雕刻机_家用玉雕机_小型万能雕刻机_凡刻雕刻机官网 | 深圳货架厂_仓库货架公司_重型仓储货架_线棒货架批发-深圳市诺普泰仓储设备有限公司 | 压力控制器,差压控制器,温度控制器,防爆压力控制器,防爆温度控制器,防爆差压控制器-常州天利智能控制股份有限公司 | 偏心半球阀-电动偏心半球阀-调流调压阀-旋球阀-上欧阀门有限公司 | 消电检公司,消电检价格,北京消电检报告-北京设施检测公司-亿杰(北京)消防工程有限公司 | 土壤检测仪器_行星式球磨仪_土壤团粒分析仪厂家_山东莱恩德智能科技有限公司 | 海外整合营销-独立站营销-社交媒体运营_广州甲壳虫跨境网络服务 焊管生产线_焊管机组_轧辊模具_焊管设备_焊管设备厂家_石家庄翔昱机械 | ETFE膜结构_PTFE膜结构_空间钢结构_膜结构_张拉膜_浙江萬豪空间结构集团有限公司 | 复合肥,化肥厂,复合肥批发,化肥代理,复合肥品牌-红四方 | Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | SOUNDWELL 编码器|电位器|旋转编码器|可调电位器|编码开关厂家-广东升威电子制品有限公司 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 铁艺,仿竹,竹节,护栏,围栏,篱笆,栅栏,栏杆,护栏网,网围栏,厂家 - 河北稳重金属丝网制品有限公司 山东太阳能路灯厂家-庭院灯生产厂家-济南晟启灯饰有限公司 | 除尘布袋_液体过滤袋_针刺毡滤料-杭州辉龙过滤技术有限公司 | 厦门ISO认证|厦门ISO9001认证|厦门ISO14001认证|厦门ISO45001认证-艾索咨询专注ISO认证行业 | 网优资讯-为循环资源、大宗商品、工业服务提供资讯与行情分析的数据服务平台 | 清管器,管道清管器,聚氨酯发泡球,清管球 - 承德嘉拓设备 | 微型气象仪_气象传感器_防爆气象传感器-天合传感器大全 | 化妆品加工厂-化妆品加工-化妆品代加工-面膜加工-广东欧泉生化科技有限公司 |