根据文档,我强制用户注销该方法signOut()
.
这是我尝试过的:
var rootRef = firebase.database().ref();
var loggedInUser = firebase.auth();
1. firebase.signOut();
2. loggedInUser.signOut();
3. rootRef.signOut();
4. signOut();
5. firebase.auth.signOut();
Run Code Online (Sandbox Code Playgroud)
我得到... is not a function
了上述五个中的每一个.我知道我对新Firebase的引用没有问题,因为firebase.database().ref();
并firebase.auth();
没有抛出错误.我还在控制台中迁移了应用程序.
编辑澄清:我有两个问题.1.为什么我的节点被覆盖了?2.为什么回调显然被称为recursivly?
我按照本指南为我的webapp实现了状态系统.我希望所有登录用户始终能够知道所有其他用户是否在线.这是我的代码:
currentGameRef = gamesInProgressRef.child(newState.currentTable);
var myConnectionsRef = currentGameRef.child("player" + newState.myPlayerNumber).child("connections");
var lastOnlineRef = currentGameRef.child("player" + newState.myPlayerNumber).child("lastOnline");
var connectedRef = firebase.database().ref('.info/connected');
connectedRef.on("value", function(snap) {
if(snap.val() == true){
var con = myConnectionsRef.push(true);
con.onDisconnect().remove();
lastOnlineRef.onDisconnect().set(firebase.database.ServerValue.TIMESTAMP);
}
});
Run Code Online (Sandbox Code Playgroud)
当我测试代码时,它会true
向每个玩家"连接" - 节点写入数千个代码.奇怪的是,每个玩家的所有其他孩子都被删除了.为什么会这样?播放器节点如下所示:
"player1" : {
"name": "Vladimir Putin",
"country": "Russia",
...,
...,
"connections" : {
...
...
}
}
Run Code Online (Sandbox Code Playgroud)
我没有在我的代码中设置"player1"-node,只是它的一个孩子.我知道100%的上述代码导致了这种行为,但我无法弄清楚原因.有人可以告诉我为什么上面的代码清除播放器节点?
我无法访问this.state
组件内的函数.我已经在SO上找到了这个问题,并将建议的代码添加到我的构造函数中:
class Game extends React.Component {
constructor(props){
super(props);
...
this.state = {uid: '', currentTable : '', currentRound : 10, deck : sortedDeck};
this.dealNewHand = this.dealNewHand.bind(this);
this.getCardsForRound = this.getCardsForRound.bind(this);
this.shuffle = this.shuffle.bind(this);
}
// error thrown in this function
dealNewHand(){
var allCardsForThisRound = this.getCardsForRound(this.state.currentRound);
}
getCardsForRound(cardsPerPerson){
var shuffledDeck = this.shuffle(sortedDeck);
var cardsForThisRound = [];
for(var i = 0; i < cardsPerPerson * 4; i++){
cardsForThisRound.push(shuffledDeck[i]);
}
return cardsForThisRound;
}
shuffle(array) {
...
}
...
...
Run Code Online (Sandbox Code Playgroud)
它仍然无法正常工作.this.state.currentRound …
错误在标题中.
我正在构建的应用程序基于React和Firebase.我正在尝试使用承诺.这是我的代码:
gamesRef.on('value').then(function(snapshot){
// find all empty games
var gamesToRemove = [];
snapshot.forEach(game => {
if(game.val().player1 == ""
&& game.val().player2 == ""
&& game.val().player3 == ""
&& game.val().player4 == ""){
gamesToRemove.push(game.key());
}
});
return gamesToRemove;
}).then(function(gamesToRemove){
// remove all empty games
for(var index in gamesToRemove){
gamesRef.child(gamesToRemove[index]).remove();
}
}, function(error){
console.log(error);
});
Run Code Online (Sandbox Code Playgroud)
我在SO上发现了这个问题,解决了同样的问题.解决方案是Firebase版本需要至少2.4才能使用promises.我使用的是旧版本,但在升级到2.4.2之后,我仍然遇到了同样的错误.我该怎么办?
编辑:修复后的代码.得到错误"gamesRef.on(...).然后不是一个函数".
gamesRef.on('value', function(snapshot){
// find all empty games
var gamesToRemove = [];
snapshot.forEach(game => {
if(game.val().player1 == ""
&& game.val().player2 == ""
&& game.val().player3 …
Run Code Online (Sandbox Code Playgroud) 我从Google Line Chart参考中复制了此代码并进行了一些小的更改:
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('number', 'Dag');
data.addColumn('number', 'Målvikt');
data.addColumn('number', 'Uppmätt vikt');
data.addRows([
[1, 37.8, 55.0],
[2, null, 69.5],
[3, null, 57],
[4, null, 18.8],
[5, null, 17.6],
[6, null, 13.6],
[7, null, 12.3],
[8, null, 29.2],
[9, null, 42.9],
[10, null, 30.9],
[11, null, 7.9],
[12, null, 8.4],
[13, null, 6.3],
[14, 30.8, 6.2]
]);
var options = {
chart: {
title: 'Box Office Earnings in First Two Weeks of Opening',
subtitle: 'in …
Run Code Online (Sandbox Code Playgroud) 我正在构建我的第一个React应用程序.在我的代码中,我使用重定向到另一个页面(一个组件)
browserHistory.push(pathToMyComponent)
Run Code Online (Sandbox Code Playgroud)
我也尝试过react-router Link-element.Link元素使我能够将数据传递到目标组件,而不会显示在URL中,如下所示:
<Link to={`/myComponent/${someData}`}>
Run Code Online (Sandbox Code Playgroud)
但现在我不想创建一个链接.相反,我想在按下按钮时执行一些操作,然后使用一些计算数据重定向.我该怎么做呢?
编辑:这是我的代码.在登录页面中,用户可以执行Facebook登录.我想要的是在登录成功后将用户重定向到大厅.我想将用户ID传递到大厅.
<Router history={browserHistory} onUpdate={() => window.scrollTo(0, 0)}>
<Route path="/" component={LoginPage}/>
<Route path="/lobby" component={Lobby}/>
</Router>
Run Code Online (Sandbox Code Playgroud)
这是我在阅读你的答案后写的.执行此操作时,将打印日志Uncaught TypeError: Cannot read property 'context' of null
this.context.router.push({ //browserHistory.push should also work here
pathname: '/lobby',
state: {userid: authData.uid}
});
Run Code Online (Sandbox Code Playgroud)
Edit2:你的意思是这样的?它给出了语法错误.
class LoginPage extends React.Component {
contextTypes = {
router: React.PropTypes.object
};
constructor(props){
super(props);
...
...
Run Code Online (Sandbox Code Playgroud) 我在Visual Studio 2015中制作了一个SSIS包.稍后,我不得不重新安装VS,因为无关的包有一些问题.现在当我尝试打开SSIS包时,我首先得到以下弹出窗口:
The 'ResourceManagerPackage' package did not load correctly.
The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users\xxx\Appdata\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml'.
Restarting Visual Studio could help resolve this issue.
Continue to show this error message?
Run Code Online (Sandbox Code Playgroud)
即使我刚刚启动VS,弹出窗口也会弹出.
单击确定后,项目无法加载.在解决方案资源管理器中,它显示"不兼容",当我将鼠标悬停在它上面时,它会显示"应用程序未安装".
我该如何解决?
编辑我已经运行了VS的修复,并手动添加了SSDT,没有任何改进.我也按照弹出窗口中的建议打开了ActivityLog并搜索了错误.我找到了这个:
Could not load file or assembly 'Microsoft.AnalysisServices.Project, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
Could not …
Run Code Online (Sandbox Code Playgroud) 我Execute SQL Task
在我的控制流中添加了一个。我将其配置为使用连接管理器。
当我按下时,Build Query
我收到一条错误消息Login failed for user xxx
。我检查了连接管理器上的设置 100 次。谷歌搜索一段时间后,我发现这可能是因为ProtectionLevel
设置为加密敏感设置。
所以为了检查这是否是导致我错误的原因,我不得不将我的 ProtectionLevelDontSaveSensitive
改为。好的,所以我在项目级别上做了这个。当我构建时出现错误,因为Package.dtsx has a different ProtectionLevel than the project.
我也需要更改包。但是我找不到设置!它不在包的属性页面上,我不知道还能在哪里查看。
有什么建议吗?
编辑:Date
当然,购买包含一个名为的列.我的错.
我有一个表,Purchases
有列CustomerId
,PhoneNumber
和Purchase
,Price
和Date
.
我想将有关客户的信息移到新表中Customers
.那包含CustomerId
和PhoneNumber
.
具有相同的行CustomerId
可以多次出现Purchases
,我只想要每个行的最新行CustomerId
,因为它将包含该PhoneNumber
客户的最新行.
我读了一些关于DISTINCT
但是从我所理解的用于查找唯一行的内容(对吧?).
我已经尝试了一些内部连接的东西,但由于我是初学者,我不觉得如果我发布它会有很大贡献:)
我正在尝试为我的数字输入标签设置默认值。这是代码:
<input id="discount-input" type="number" step="any" value=@Model.OrderDiscount />
Run Code Online (Sandbox Code Playgroud)
Model.OrderDiscount
是一个十进制值,保存为2,00。当我运行代码时,输入字段只是空白。我尝试了Model中的另一个变量,效果很好。虽然那是一个整数,所以我也进行了硬编码value=2.00
。我还尝试了使用step =“ 0.01”,step =“ 0.1”,step =“ 1”和step =“ any”的所有不同组合,结果相同。
我知道您认为OrderDiscount
只是必须为空,但是没有!我用调试器检查了10次。到底是怎么回事?
编辑:我尝试在模型上的另一个字段也包含一个十进制值。均未显示。看来我无法使用变量来设置默认的十进制值。
javascript ×5
firebase ×3
reactjs ×2
ssis ×2
asp.net-mvc ×1
c# ×1
charts ×1
html ×1
promise ×1
razor ×1
react-router ×1
sql ×1
sql-server ×1
t-sql ×1