@[TOC]OpenLayers的import失败问题
一般情况,只需要在new的地方加上对应的包名即可解决问题。
但是有时候官方文档中的例子并不是new,比如
import {defaults as defaultInteractions, Pointer as PointerInteraction} from 'ol/interaction.js';
...
...
...
var Drag = (function (PointerInteraction) {
function Drag() {
PointerInteraction.call(this, {....
....
....
var map = new Map({
interactions: defaultInteractions().extend([new Drag()]),
对于以上情况,如下修改即可:
var PointerInteraction = ol.interaction.Pointer;//这样导入不报错
var Drag = (function (PointerInteraction) {
function Drag() {
PointerInteraction.call(this, {
…
var map = new ol.Map({
interactions: ol.interaction.defaults().extend([new Drag()]),