我正在尝试遵循 firebase 文档并使用聚合物将图像上传到 firebase。
这就是我所拥有的
_pushToFirebase: function() {
// SLUGGING THE NAME B4 WE EVEN SAVE IT!!
var sluggedname = this._slugify(this.$.crewName.value);
//FOR THE IMAGE
var file = this.$.crewProfilePic.value;
// Upload file
var uploadTask = this.$.query.storageRef.child('/crewprofileimages/' + file.name).put(file);
// Listen for state changes, errors, and completion of the upload.
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, // or 'state_changed'
function(snapshot) {
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
console.log('Upload is ' + progress + '% done');
switch (snapshot.state) {
case firebase.storage.TaskState.PAUSED: // or 'paused'
console.log('Upload is paused');
break;
case firebase.storage.TaskState.RUNNING: // or 'running'
console.log('Upload is running');
break;
}
}, function(error) {
switch (error.code) {
case 'storage/unauthorized':
// User doesn't have permission to access the object
console.log('You dont have permission to access object');
break;
case 'storage/canceled':
// User canceled the upload
console.log('User cancelled upload');
break;
case 'storage/unknown':
// Unknown error occurred, inspect error.serverResponse
console.log(error.code);
break;
}
}, function() {
// Upload completed successfully, now we can get the download URL
var downloadURL = uploadTask.snapshot.downloadURL;
});
// PUSHING TO FIREBASE
this.$.query.ref.push({
name: this.$.crewName.value,
description: this.$.crewDescription.value,
createddate: new Date().toString(),
creator: this.$.createcrewlogin.user.uid,
slug: sluggedname,
profileimage: downloadURL,
members: {
memberuserid: this.$.createcrewlogin.user.uid,
}
});
},
firebase 查询看起来像这样
<!--STORE THE DATA IN CREWS DEFAULT SECTION-->
<firebase-query
id="query"
data="{{mycrews}}"
path="/crews">
</firebase-query>
每当我点击提交。我在控制台中收到此错误
cannot read property of 'child' of undefined
我该如何解决这个问题?