2020-08-04 es6+ol

新建文件夹并安装依赖

mkdir new-project && cd new-project
npm init
npm install ol
npm install --save-dev parcel-bundler

新建index.js

import 'ol/ol.css';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';

const map = new Map({
  target: 'map',
  layers: [
    new TileLayer({
      source: new OSM()
    })
  ],
  view: new View({
    center: [0, 0],
    zoom: 0
  })
});

新建index.html



  
    
    Using Parcel with OpenLayers
    
  
  
    

运行脚本

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "parcel index.html",
    "build": "parcel build --public-url . index.html"
  },
  "author": "",
  "license": "ISC"
}

脚本命令

运行

npm start

打包

npm run build

你可能感兴趣的:(2020-08-04 es6+ol)