聚合物 3:聚合物构建后代码不起作用



my polymer.json

{
"entrypoint": "index.html",
"shell": "src/boo-blogger/boo-blogger.js",
"sources": [
"images/*",
"fonts/*"
],
"extraDependencies": [
"manifest.json",
"node_modules/@webcomponents/webcomponentsjs/*.js",
"node_modules/web-animations-js/web-animations-next-lite.min.js",
"node_modules/@webcomponents/webcomponentsjs/bundles/*.js"
],
"builds": [
{
"name": "es6",
"bundle": true,
"browserCapabilities": [
"es2015",
"modules"
],
"js": {
"minify": true,
"transformModulesToAmd": true
},
"html": {
"minify": true
},
"css": {
"minify": true
},
"addServiceWorker": true
}
],
"npm": true,
"lint": {
"rules": [
"polymer-3"
]
}
}

我遇到了问题

article-list.js:5 Uncaught (in promise) TypeError: _booBlogger.html$1 is not a function

文章列表.js通过路由导入动态。所以我尝试以不同的方式尝试一些构建选项。我发现当我在没有捆绑包的情况下构建时,构建的代码可以工作。我不知道为什么我的代码不能按polymer build捆绑。如果有人对问题感到好奇并需要完整的源代码。联系我

工具摘要

  1. 系统: 乌班图 16.04
  2. 聚合物:1.7.7
  3. 节点:10.1.0

在你的 polymer.json 中,你需要添加:

"fragments": [
"src/article-list.js"
],

我想你忘了在你的来源中添加文章列表.js。由于它是在文档中编写的,因此您必须将动态导入的模块包含在 polymer.json 中的"源"中。见 https://polymer-library.polymer-project.org/3.0/docs/apps/build-for-production#dynamic

最新更新