我需要将此聚合物元素附加到 index.html 中,我没有问题,但问题是我无法将任何内容附加到“项目”div 我该怎么做?我认为该元素尚未附加到 index.html 页面,因此脚本无法捕获“项目”div。
<link rel="import" href="../bower_components/polymer/polymer.html">
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<link rel="import" href="../bower_components/paper-icon-button">
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<dom-module id="sample-page">
<style>
</style>
<template>
<div class="items">
</div>
</template>
</dom-module>
<script>
Polymer({
is: "sample-page",
});
$(document).ready(function(){
;
var rootRef = "myfirebase ref......."
rootRef.on("child_added", function (snapshot, prevChildKey) {
var pointData = snapshot.val();
snapshot.forEach(function (childSnap) {
$('#items').append( pointData.user);
var key = childSnap.key();
//console.log('here come');
// console.log("Title: " + pointData.user);
})
// });
// });
</script>