typescript - 离子构建说:类型''上不存在属性''
问题描述
当我尝试在 ionic3 中构建此代码时,它向我显示此警报:“MapService”类型上不存在属性“tempIcon”。
离子构建
import { Injectable } from "@angular/core";
import { BaseLayersService } from "./base-layers.service";
import { WmsLayersService } from "./wms-layers.service";
import { ToastController } from 'ionic-angular';
import L from "leaflet";
@Injectable()
export class MapService {
public map: L.Map;
constructor(private wmsLayersService: WmsLayersService, private baseLayersService: BaseLayersService, public toastCtrl: ToastController) {
}
loadMap() {
this.tempIcon = L.icon({
iconUrl: 'assets/imgs/position.png',
shadowUrl: '',
iconSize: [48, 48], // size of the icon
shadowSize: [0, 0], // size of the shadow
iconAnchor: [48, 48], // point of the icon which will correspond to markers location
shadowAnchor: [0, 0], // the same for the shadow
popupAnchor: [48, 48] // point from which the popup should open relative to the iconAnchor
});
const map = L.map("map", {
//layers: [this.baseLayersService.baseLayers.OpenStreetMap, this.wmsLayersService.wmsLayers.Falabella]
layers: [this.wmsLayersService.wmsLayers.Falabella, this.baseLayersService.baseLayers.CartoDB ]
});
L.control.layers(this.baseLayersService.baseLayers, this.wmsLayersService.wmsLayers).addTo(map);
L.control.scale().addTo(map);
解决方案
我想你没有宣布它。试着像这样声明它
public map: L.Map;
public tempIcon: any;
推荐阅读
- sql - 如何在 sql/snowflake 中获取每个月的最大天数
- elasticsearch - Gremlin 对多个属性进行分组
- python - VIsual Studio 代码不会突出显示 Keras 代码中的错误
- asp.net-core - EF Core 未将主键传递给查询
- amazon-web-services - 将日期作为变量的 ETL 的 AWS Glue 作业参数化
- c++ - UML图中的指针
- laravel - 有什么区别?以及如何使用它们?
- jmeter - 如何设置线程组和 CSV 数据集配置以在 Jmeter 中读取大型 CSV
- c++ - 基于动态选择类型的C++模板使用
- google-cloud-platform - GCP - 如何为 setOrgPolicy 设置 Beta 权限