3
我就遷移到聚合物1.0選擇元件(聚合物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
我嘗試添加一個id到div,並喜歡選擇它這樣:
height = this.$.content.scrollHeight;
但儘管內容中有很多文字,但這給我的值爲0。
我從ready
函數調用此代碼。
我是否正確選擇元素?
非常感謝,做到了。現在我在選擇屬性的語法上遇到了一些麻煩,但我會在另一個問題中提出這個問題。 – Tyler