我正在尝试从“@here/flexpolyline”导入 {decode},它不在 script.js 中运行。
我创建了一个webpack.config.js并创建了一个bundle.js来导入npm,但它仍然不起作用。
https://glitch.com/edit/#!/google-maps-powerapps-iframe
如有任何帮助,我们将不胜感激。
您会发现,在 Glitch.com 中,您必须使用 Webpack 捆绑 npm 模块,并且该捆绑的结果 (
bundle.js
) 必须正确包含在您的 HTML 中。正确设置 webpack.config.js
后,生成您的 bundle.js
并将其链接到您的 index.html
中。这可能只是引用了一个不存在的文件,或者您的 Webpack 设置不正确。这是一个最小的设置,应该可以让您上路。
webpack.config.js:
const path = require('path');
module.exports = {
entry: './src/script.js',
output: {
path: path.resolve(__dirname, 'public'),
filename: 'bundle.js',
},
};
src/script.js:
import { decode } from '@here/flexpolyline';
console.log(decode); // Test your import
index.html:
<script src="/bundle.js"></script>