【发布时间】:2017-04-01 16:04:00
【问题描述】:
我想很好地封装我的聚合物组件,但现在如果我尝试将任何外部模块导入组件中,我会收到未定义的“导入”错误。
我使用 Webpack 来打包我的应用程序,但这只会打包我的 javascript 文件。
有没有办法将我的 Polymer 组件封装到单个 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>
【问题讨论】:
标签: node.js import webpack polymer node-modules