这可以通过jQuery轻松完成:
var msgs = $(".messages ul")
var scroll = false
if( msgs[0].scrollHeight === (msgs.scrollTop() + msgs.outerHeight() ) )
{
scroll = true
}
$scope.messages.push(data)
if(scroll)
{
setTimeout(function(){
msgs.scrollTop(msgs[0].scrollHeight) // Allow it to update!
},0)
}
Run Code Online (Sandbox Code Playgroud)
为了给出一些上下文,ul是消息的容器,我迭代数组$scope.messages,如果容器滚动到底部,它将坚持到底部.这个实现对我有用.
现在,我最近学会了如何在角度中真正使用jQuery.但我想知道,我将如何在纯AngularJS中实现这样的效果?
在Arduino IDE中,我收到有关如何声明我的构造函数两次的错误.
这是它的代码:
tond.h
#ifndef TOND_H
#define TOND_H
class Tondeuse {
public:
Tondeuse();
Tondeuse(int,int);
};
#endif
Run Code Online (Sandbox Code Playgroud)
tond.cpp
#ifndef TOND
#define TOND
#include "arduino.h"
#include "tond.h"
Tondeuse::Tondeuse()
{
}
Tondeuse::Tondeuse(int h, int w)
{
Serial.println("Hello");
}
#endif
Run Code Online (Sandbox Code Playgroud)
而错误:
Tondeuse.cpp.o: In function `Tondeuse':
/tond.cpp:11: multiple definition of `Tondeuse::Tondeuse()'
tond.cpp.o:C:\Users\DEPANNE\AppData\Local \Temp\build6942484698459603114.tmp/tond.cpp:11: first defined here
Tondeuse.cpp.o: In function `Tondeuse':
/tond.cpp:11: multiple definition of `Tondeuse::Tondeuse()'
tond.cpp.o:C:\Users\DEPANNE\AppData\Local \Temp\build6942484698459603114.tmp/tond.cpp:11: first defined here
Tondeuse.cpp.o: In function `Tondeuse':
/tond.cpp:16: multiple definition of `Tondeuse::Tondeuse(int, int)'
tond.cpp.o:C:\Users\DEPANNE\AppData\Local\Temp\build6942484698459603114.tmp/tond.cpp:16: first defined here
Tondeuse.cpp.o: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Telegram 登录小部件。
我已在登录页面中插入以下脚本:
<script async="" src="https://telegram.org/js/telegram-widget.js?4" data-telegram-login="<name of bot>" data-size="large" data-auth-url="http://local.<domain>/tg" data-radius="0" data-request-access="write"></script>
Run Code Online (Sandbox Code Playgroud)
只要显示登录小部件,此操作就有效。
当我单击“使用 Telegram 登录”按钮时,如果我想登录该网站,它会正确地要求我接受/拒绝。但随后就没有再发生任何事情。
通过调查网络请求,我发现电报服务器响应如下:
{"error":"NOT_AUTHORIZED","html":"<button class=\"btn tgme_widget_login_button\" onclick=\"return TWidgetLogin.auth();\"><i class=\"tgme_widget_login_button_icon\"><\/i>Log in with Telegram<\/button>","origin":"http:\/\/local.<domain>"}
Run Code Online (Sandbox Code Playgroud)
有什么是我应该做的而错过的吗?
我确实与 @BotFather 进行了交谈,将域名设置为http://local.<domain>.
登录时,我还在客户端中收到来自 Telegram 的消息,告诉我:
您已通过@成功登录local.furry.cafe。该网站收到您的姓名、用户名和个人资料图片。
可能有问题的事情:
local.<domain>是我的 /etc/hosts 的一部分,但这应该不是问题,对吧?