相关疑难解决方法(0)

如何在反应 16.4.1 中使用传单折线装饰器

我正在尝试在 react 16.4.1 中使用传单插件 polylinedecorator(所以没有钩子)。但是,我能够找到的关于如何在 react 中使用此插件的唯一示例是使用钩子(请参阅:如何将 polylinedac​​orator 与 react 传单一起使用),我不确定如何调整它以便能够在我的代码。

到目前为止,我拥有的是这个 polylinedecorator 组件:

import React, { Component } from "react";
import { Polyline } from "react-leaflet";
import L from "leaflet";
import "leaflet-polylinedecorator";

export default class PolylineDecorator extends Component {
  componentDidUpdate() {
    if (this.props.map) {
        const polyline = L.polyline(this.props.positions).addTo(this.props.map);

        L.polylineDecorator(polyline, {
            patterns: [
                {
                  offset: "100%",
                  repeat: 0,
                  symbol: L.Symbol.arrowHead({
                    pixelSize: 15,
                    polygon: false,
                    pathOptions: { stroke: true }
                  })
                }
              ]
        }).addTo(this.props.map);
    }
  }

  render() {
    return …
Run Code Online (Sandbox Code Playgroud)

leaflet reactjs react-leaflet polyline-decorator

3
推荐指数
1
解决办法
1552
查看次数