我在ES6中创建类。 该班有私人成员:
export class Geo{
constructor(){
this.#setView();
this.#setMap();
}
#setView(){
this.view = new View({
center: location.Reykjavík,
projection: get,
zoom: 0,
constrainResolution: false,
});
}
#setMap(){
this.map = new Map({
controls: defaultControls().extend([
new ScaleLine()
]),
layers: [new Tile({source: new OSM()})],
target: 'map',
view: this.view
});
}
getMap(){
return this.map;
}
}
在终端我得到这个错误:
ERROR in ./src/geomodels/geo.js 13:13
Module parse failed: Unexpected character '#' (13:13)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| constructor(){
> this.#setView();
| this.#setMap();
| }
我的问题是为什么这个字符#是错误的?如何在课堂上使用私人会员?