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);
	}

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

钥钥睡着了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值