<paper-toolbar>上的哪个querySelector更好?

时间:2015-11-21 23:31:12

标签: polymer polymer-1.0

var toolbar = Polymer.dom(document).querySelector('#main-toolbar')
var toolbar = document.querySelector('#main-toolbar');
<paper-toolbar id="main-toolbar">

1)当document.querySelector成为影子dom元素时,为什么paper-toolbar可以使用querySelector?或另一种方式来说明......为什么它适用于本地dom中的元素?

2)因为这两个Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 343, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 177, in fetch_command commands = get_commands() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 72, in get_commands for app_config in reversed(list(apps.get_app_configs())): File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/apps/registry.py", line 137, in get_app_configs self.check_apps_ready() File "/Library/Frameworks/Python.framework/Vers`enter code here`ions/3.5/lib/python3.5/site-packages/django/apps/registry.py", line 124, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 都有效,哪个更好用?

1 个答案:

答案 0 :(得分:1)

工具栏不在聚合物元素内。 你可以使用document.querySelector('#main-toolbar'); 这里不需要使用Polymer API(聚合物元素是HTML元素)。 聚合物API可用于访问阴影/阴影DOM(聚合物元素内部)。