这是我遇到的错误
bow_rect = bow.get_rect()
# reverse scale mouse coordinates (1/2x)
angle = math.degrees(math.atan2(player.centery - my/2, mx/2 - player.centerx)) + 180
rotated_bow = pygame.transform.rotate(bow,angle)
pygame.draw.rect(display,(255,255,255),player)
display.blit(rotated_bow, (int(player.x+25)-int(rotated_bow.get_width()/2),
int(player.y+25)-int(rotated_bow.get_height()/2)))
# scale surface to screen (2x)
screen.blit(pygame.transform.scale(display,(screen_width,screen_height)),(0,0))
pygame.display.update()
clock.tick(60)
我的其他firebase函数(通常是firebase auth)执行得很好(不在此文件中)。我输入的是错误的东西吗? 这是我的称呼方式:
Uncaught TypeError: _config_fire__WEBPACK_IMPORTED_MODULE_2__.default.on is not a function
,如果需要的话,这里是配置
/* eslint-disable react/no-unused-state */
/* eslint-disable new-cap */
/* eslint-disable class-methods-use-this */
import React, { Component } from 'react';
import { Map } from 'immutable';
import fbase from '../config/fire';
import Entry from './leaderboard_entry';
class Leaderboard extends Component {
constructor(props) {
super(props);
this.state = {
users: Map(),
};
}
initialize() {
fbase.on('value', (snapshot) => {
const newUserState = snapshot.val();
this.setState({ users: Map(newUserState) });
}, (error) => {
console.error(error);
});
}
详细信息已编辑。
答案 0 :(得分:1)
错误是正确的,您正在尝试在Firebase on上错误地执行References的App。更新代码以访问Database并获取对数据路径的引用,然后就可以使用值了:
fbase.database().ref('/some-path').on('value', (snapshot) => {
const newUserState = snapshot.val();
this.setState({ users: Map(newUserState) });
}, (error) => {
console.error(error);
});
此外,您还需要为正在使用的任何模块进行静态导入:
import 'firebase/auth';
import 'firebase/database';
希望有帮助!
答案 1 :(得分:0)
您需要导入firebase / firestore软件包。
您的代码应如下所示。
import firebase from 'firebase';
import 'firebase/firestore';
const firebaseConfig = {
apiKey:
authDomain:
databaseURL:
projectId:
storageBucket:
messagingSenderId:
appId:
};
const fbase = firebase.initializeApp(firebaseConfig);
export default fbase;