我开始在typescript和typescript的amd模块中使用requirejs。
现在我正在使用带有typescript的HereMaps,这些函数只被一个d.ts文件引用。
我如何引用/导入Here Maps、google maps或openstreetmaps到TypeScript2中,以确保它将由requirejs加载?
发布于 2018-10-24 17:26:43
我觉得不是一个完美的组合,还是用webpack或者类似的东西比较好
我通过在tsconfig.json中将typescript模块切换到AMD来解决这个问题
{
"compilerOptions": {
"module": "AMD",
"target": "es5",
"sourceMap": true,
"declaration": false
},
"exclude": [
"node_modules"
]
}然后,您必须使用请求来导入引用
import H = require('heremaps-core');定义外部参照后
requirejs.config({
shim: {
'heremaps-core': {
exports: 'H'
},
'heremaps-ui': ['heremaps-core'],
'heremaps-service': ['heremaps-core'],
'heremaps-events': ['heremaps-core'],
'hogan': {
exports: 'Hogan'
}
},
paths: {
'jquery': [
'https://code.jquery.com/jquery-3.1.1.min',
'https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.1.min',
'lib/jquery-3.1.1.min'
],
'hogan': [
'https://twitter.github.io/hogan.js/builds/3.0.1/hogan-3.0.1.js',
'lib/hogan.min'
],
'google.maps': [
'https://maps.googleapis.com/maps/api/js?v=3.21 &key=AIzaSyBtw3pgNVNPacgQGwLQt1nUbBrqGW-De90'
],
'heremaps-core': [
'https://js.api.here.com/v3/3.0/mapsjs-core'
],
'heremaps-ui': [
'https://js.api.here.com/v3/3.0/mapsjs-ui'
],
'heremaps-service': [
'https://js.api.here.com/v3/3.0/mapsjs-service'
],
'heremaps-events': [
'https://js.api.here.com/v3/3.0/mapsjs-mapevents'
]
}
});我不确定这是不是全部。我已经有一年没有参与这个项目了。
https://stackoverflow.com/questions/40964920
复制相似问题