我的< script>在我的< dom-module> [英] Should my <script> be inside my <dom-module>?
问题描述
< script>
标签放在我的< dom-module> / code>标签。 E.G: < dom-module id =>
< template>
< style>
< / style>
< / template>
< script>聚合物({});
< / script>
< / dom-module>
但是我也看到了< script>
标签放在< dom-module>
标签之外。 E.G:
< dom-module id =>
< template>
< style>
< / style>
< / template>
< / dom-module>
< script>聚合物({});
< / script>
两种方式似乎都可以正常工作。哪种方式被认为是正确的?你可以解释吗?
解决方案主要存在 dom-module
,以便 Polymer()
调用可以定位属于注册的模板,样式和其他dom资源。脚本本身可以在任何地方生活(只要相应的 dom-module
先验存在)。
人们通常把脚本放在模块中,因为它提供了一个整洁的包,但它仍然是可选的。
I've been developing with polymer and I've always put my <script>
tags inside my <dom-module>
tags. E.G:
<dom-module id="">
<template>
<style>
</style>
</template>
<script>
Polymer({});
</script>
</dom-module>
But I've also seen the <script>
tags put outside of the <dom-module>
tags. E.G:
<dom-module id="">
<template>
<style>
</style>
</template>
</dom-module>
<script>
Polymer({});
</script>
Both ways seem to work fine. Which way is considered correct though? Can you explain?
解决方案 The dom-module
exists primarily so that the Polymer()
call can locate template, style, and other dom resources that belong to a registration. The script itself can live anywhere (as long as the corresponding dom-module
exists a priori).
Folks typically put the script inside the module as it provides a tidy bundle, but it remains optional.
这篇关于我的< script>在我的< dom-module>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!