VUE前端问题

一、图表内容不显示

watch: {
    chartData3: {
      handler() {
        this.init();
      },
    },
    timeData3: {
      handler() {
        this.init();
      },
    },
  },

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

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

解决方法:

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

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

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

init() {
		this.olSource_line = new VectorSource();
        console.log("this.viewZoom1:", this.viewZoom);
		this.olLayer_line = new VectorLayer({
			source: this.olSource_line,
			style: (feature) => {
				console.log("this.viewZoom2:", this.viewZoom);
				let coords = feature.getGeometry().getCoordinates();
				return [
					new Style({
						stroke: new Stroke({
							color: this.style.line_stroke,
							width: this.viewZoom + 2,
						}),
					}),
					...this.getPointsStyle(coords)
				]
			},
		});
		this.olMap.addLayer(this.olLayer_line);
}

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

解决方法: 

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

init() {
		this.olSource_line = new VectorSource();
		this.olLayer_line = new VectorLayer({
			source: this.olSource_line,
			style: (feature) => {
				console.log("this.viewZoom:", this.viewZoom);
				let coords = feature.getGeometry().getCoordinates();
				return [
					new Style({
						stroke: new Stroke({
							color: this.style.line_stroke,
							width: this.viewZoom + 2,
						}),
					}),
					...this.getPointsStyle(coords)
				]
			},
		});
		this.olMap.addLayer(this.olLayer_line);

		// 添加地图缩放事件监听器
		this.olMap.on('moveend', () => {
			this.viewZoom = this.olMap.getView().getZoom();
			this.updateLineStyle(); // 更新轨迹线样式
		});
	}
	updateLineStyle() {
		// 在这里更新轨迹线的样式,可以根据新的 this.viewZoom 值进行相应的样式调整
		let styleFunction = (feature) => {
			let coords = feature.getGeometry().getCoordinates();
			console.log("this.viewZoom:", this.viewZoom);
			return [
				new Style({
					stroke: new Stroke({
						color: this.style.line_stroke,
						width: this.viewZoom + 2,
					}),
				}),
				...this.getPointsStyle(coords)
			];
		};

		this.olLayer_line.setStyle(styleFunction);
	}

相关推荐

  1. 前端面试问题汇总 - Vue

    2024-03-11 23:44:02       32 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-11 23:44:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-11 23:44:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-11 23:44:02       87 阅读
  4. Python语言-面向对象

    2024-03-11 23:44:02       96 阅读

热门阅读

  1. AcWing16. 替换空格

    2024-03-11 23:44:02       42 阅读
  2. 安卓基础--application详解

    2024-03-11 23:44:02       46 阅读
  3. js的同步异步

    2024-03-11 23:44:02       41 阅读
  4. Android Selinux详解[一]---整体介绍

    2024-03-11 23:44:02       43 阅读
  5. android:textDirection=“anyRtl“在说什么?

    2024-03-11 23:44:02       45 阅读
  6. PiflowX-TopN组件

    2024-03-11 23:44:02       43 阅读
  7. LeetCode 0299.猜数字游戏:计数

    2024-03-11 23:44:02       49 阅读
  8. IOS面试题object-c 61-70

    2024-03-11 23:44:02       40 阅读