gpt4 book ai didi

dart - 将Polymer Dart编译为JS后出错。 (尚未配置 “smoke”库)

转载 作者:行者123 更新时间:2023-12-03 03:44:38 25 4
gpt4 key购买 nike

Аfter将Dart代码(使用Dart Polymer)编译为JS。我收到以下错误:

Uncaught Exception: The "smoke" library has not been configured.
Make sure you import and configure one of the implementations
(package:smoke/mirrors.dart or package:smoke/static.dart).

有时消息是:
No elements registered in a while, but still waiting on 1 element to be registered. Check that you have a class with an @CustomTag annotation for each of the following tags: 'app-element'

怎么了这是我的代码:

更新:现在,改进了 pub build之后的代码,并且可以正常工作。我更改文件夹/文件结构并将聚合物更新为最新版本。

pubspec.yaml
name: app
dependencies:
browser: any
#do not forget update to latest version by running pub update
polymer: any
transformers:
- polymer:
entry_points:
- web/main.html

web / templates / ui-elements.html

<polymer-element name="app-globals"></polymer-element>

<polymer-element name="app-element">
<template>
<link rel="stylesheet" href="/main.css"/>
<content></content>
</template>
<script type="application/dart" src="ui-elements.dart"></script>
</polymer-element>

网站/模板/ui-elements.dart

@CustomTag('app-globals')
class AppGlobals extends PolymerElement{
AppGlobals.created() : super.created();
}

@CustomTag('app-element')
class AppElement extends PolymerElement {
AppElement.created() : super.created();
}

web / main.html (虚拟条目文件)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body>
<app-element></app-element>
<script type="application/dart" src="main.dart"></script>
</body>
</html>

网站/main.dart

import 'package:polymer/polymer.dart';

main() {
initPolymer();
}

@whenPolymerReady
void onReady() {
}

web / main.html pub build之后的(入口点)。编译后的真实困惑。如此多的js文件,其中一些文件甚至超过300kb。

<!DOCTYPE html><html lang="en"><head><script src="packages/web_components/webcomponents.min.js"></script><script src="packages/web_components/dart_support.js"></script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body><div hidden=""><style shim-shadowdom="">
/*******************************
Flex Layout
*******************************/

html /deep/ [layout][horizontal], html /deep/ [layout][vertical] {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}

html /deep/ [layout][horizontal][inline], html /deep/ [layout][vertical][inline] {
display: -ms-inline-flexbox;
display: -webkit-inline-flex;
display: inline-flex;
}

......tons of other styles...........

</style>

<script src="packages/polymer/src/js/polymer/polymer.min.js"></script>

<script>
// TODO(sigmund): remove this script tag (dartbug.com/19650). This empty
// script tag is necessary to work around a bug in Chrome 36.
</script>

<!-- unminified for debugging:
<link rel="import" href="src/js/polymer/layout.html">
<script src="src/js/polymer/polymer.js"></script>
-->
<polymer-element name="app-globals"></polymer-element>

<!-- APP ELEMENT -->
<polymer-element name="app-element" class="bck-medusa w-100 h-100">
<template>
<link rel="stylesheet" href="../main.css">
<content></content>
</template>
</polymer-element>
</div>
<script src="main.html.polymer.bootstrap.dart.js" async=""></script>


</body></html>

最佳答案

使用initPolymer时不需要@whenPolymerReady。整个main()方法在您的示例中是多余的。

您是否在pubspec.yaml的Polymer变压器配置中正确注册了进入页面?

Smoke需要一个变压器,但是如果您正确配置了Polymer变压器,则包括Smoke变压器。

关于dart - 将Polymer Dart编译为JS后出错。 (尚未配置 “smoke”库),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29900958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com