我正在迁移到 Polymer 1.0
这是我的模板:
<template>
<div class="scroll">
<div class="content">
<content></content>
</div>
<div class="bar barY"></div>
</div>
</template>
内容被主 html 文件中的文本填充。
我需要获取此 div 的滚动高度。我曾经做过:
height = $(this.shadowRoot).find('.content')[0].scrollHeight;
但这不再起作用了:
Uncaught TypeError: Cannot read property 'scrollHeight' of undefined
我尝试向 div 添加一个 id,然后像这样选择它:
height = this.$.content.scrollHeight;
但这给了我一个 0 的值,即使内容中有很多文本。
我正在从ready
函数中调用此代码。
我是否正确选择了元素?