• VUE前端问题


    一、图表内容不显示

    1. watch: {
    2. chartData3: {
    3. handler() {
    4. this.init();
    5. },
    6. },
    7. timeData3: {
    8. handler() {
    9. this.init();
    10. },
    11. },
    12. },

     添加上面代码可以动态监控数据,实现图表的展示。

    二、背景图片报错显示不出来

    解决方法:

    background: url(~@/assets/login/e.png)

    将引入改为 ~@方式引入即可
    ~@的意思: @是webpack设置的路径名,代表的是src目录,可以在build / webpack.base.conf.js更改设置

    三、轨迹不随地图缩放而缩放

    1. init() {
    2. this.olSource_line = new VectorSource();
    3. console.log("this.viewZoom1:", this.viewZoom);
    4. this.olLayer_line = new VectorLayer({
    5. source: this.olSource_line,
    6. style: (feature) => {
    7. console.log("this.viewZoom2:", this.viewZoom);
    8. let coords = feature.getGeometry().getCoordinates();
    9. return [
    10. new Style({
    11. stroke: new Stroke({
    12. color: this.style.line_stroke,
    13. width: this.viewZoom + 2,
    14. }),
    15. }),
    16. ...this.getPointsStyle(coords)
    17. ]
    18. },
    19. });
    20. this.olMap.addLayer(this.olLayer_line);
    21. }

    地图缩放时this.viewZoom1在改变,但是this.viewZoom2不变。

    解决方法: 

    添加监听函数监听数据变化

    1. init() {
    2. this.olSource_line = new VectorSource();
    3. this.olLayer_line = new VectorLayer({
    4. source: this.olSource_line,
    5. style: (feature) => {
    6. console.log("this.viewZoom:", this.viewZoom);
    7. let coords = feature.getGeometry().getCoordinates();
    8. return [
    9. new Style({
    10. stroke: new Stroke({
    11. color: this.style.line_stroke,
    12. width: this.viewZoom + 2,
    13. }),
    14. }),
    15. ...this.getPointsStyle(coords)
    16. ]
    17. },
    18. });
    19. this.olMap.addLayer(this.olLayer_line);
    20. // 添加地图缩放事件监听器
    21. this.olMap.on('moveend', () => {
    22. this.viewZoom = this.olMap.getView().getZoom();
    23. this.updateLineStyle(); // 更新轨迹线样式
    24. });
    25. }
    26. updateLineStyle() {
    27. // 在这里更新轨迹线的样式,可以根据新的 this.viewZoom 值进行相应的样式调整
    28. let styleFunction = (feature) => {
    29. let coords = feature.getGeometry().getCoordinates();
    30. console.log("this.viewZoom:", this.viewZoom);
    31. return [
    32. new Style({
    33. stroke: new Stroke({
    34. color: this.style.line_stroke,
    35. width: this.viewZoom + 2,
    36. }),
    37. }),
    38. ...this.getPointsStyle(coords)
    39. ];
    40. };
    41. this.olLayer_line.setStyle(styleFunction);
    42. }

  • 相关阅读:
    mysql<回表,覆盖索引,最左匹配,索引下推>
    Mybatis之动态sql、模糊查询、查询返回结果集的处理、分页查询与特殊字符处理
    跟我学C++中级篇——右值引用和万能引用
    C# 构造函数
    TMS320F28335使用多个串口时,SCIRXST Register出现错误
    通信原理板块——脉冲编码调制(PCM)
    世界杯优化算法及其Python实现
    【Mysql】第7篇--JdbcTemplate(jdbc模版)
    UML/SysML和流浪地球的地球发动机
    Spring之AOP原理及总结
  • 原文地址:https://blog.csdn.net/qq_45764950/article/details/135659489