1
我想保留我的聚合物组件很好地封装,但现在如果我尝试将任何外部模块导入到组件中,我会得到一个未定义的“导入”错误。是否可以将模块导入聚合物组件?
我使用Webpack捆绑我的应用程序,但这只打包了我的JavaScript文件。
有没有办法让我的聚合物组件封装到一个单一的HTML文件或我必须分开的JS部分,当涉及到进口?
例子:
<link rel="import" href="../bower_components/polymer/polymer.html">
<dom-module id="my-new-view">
<template>
<style>
</style>
<h1>New view</h1>
</template>
<script>
import { myConstant } from '../module.js'; //<---- this throws error for the import'
Polymer({
is: 'my-new-view'
});
</script>
</dom-module>