我正在尝试在我的网站上启用谷歌登录.该按钮有效,与我的帐户同步,但我无法从谷歌访问userId.这就是我的想法.
<script type="text/javascript">
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://plus.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
Run Code Online (Sandbox Code Playgroud)
这是我试图获取用户ID的地方.在控制台中,我收到了Uncaught ReferenceError: gapi is not defined.我认为我gapi在上面的源代码中调用的错误消息.任何帮助或建议将不胜感激.
$('document').ready(function(){
var request = gapi.client.plus.people.get({
'userId' : 'me'
});
request.execute(function(resp) {
console.log('ID: ' + resp.id);
console.log('Display Name: ' + resp.displayName);
console.log('Image URL: ' + resp.image.url);
console.log('Profile URL: ' + resp.url);
});
});
Run Code Online (Sandbox Code Playgroud) 我正在将一个项目从 Firebase 版本 8 更新到版本 9。我有条件过滤查询,其结构过去如下:
let query = db.collection("collectionName").orderBy("timestamp")
if (filters.selectedStaff) {
query = query.where("id", "==", filters.selectedStaff.id);
}
if (filters.selectedStudent) {
query = query.where("studentIDs", "array-contains", filters.selectedStudent.id);
}
Run Code Online (Sandbox Code Playgroud)
Then the query gets executed in a hook that rerenders everytime the filters change. Using Version 8, this works perfectly.
In version 9, queries are now build to follow a format where each query is passed as a parameter to the query function. A normal query would look like:
query(collection(db, "collectionName"), where("id", …Run Code Online (Sandbox Code Playgroud) I've seen a few questions related to this topic, but none that tackle the issue head-on in a pure way. useContext is a great tool for minimizing prop-drilling and centralizing key data needed across your app; however, it comes at a cost that I'm trying to minimize.
The closest issue to the one I'm describing here was asked two years ago here. The question didn't gain a lot of traction and the only answer basically says call the context …
我正在使用 Material UI DataGrid,我的一列包含日期。Material UI文档说将列数组中的类型设置为“日期”,我已经这样做了:
{
field: "submittedAt",
headerName: "Submitted",
minWidth: 150,
flex: 2,
type: "date",
headerClassName: "tableHeader",
cellClassName: "hoverPointer"
}
Run Code Online (Sandbox Code Playgroud)
然后我使用 Luxon 将时间戳转换为 MM/dd/yyyy 格式
if (r.data().submittedAt) {
const d = DateTime.fromMillis(r.data().submittedAt.toMillis());
requestedDate = d.toFormat('MM/dd/yyyy')
}
Run Code Online (Sandbox Code Playgroud)
然后使用requestedDate设置列中单元格的值。当我对数据进行排序时,该列仍然按字符串比较器而不是按日期排序:
我不确定我做错了什么,而且我似乎在文档或以前的帖子中找不到太多支持。我知道我可以将日期设置为 yyyy/MM/dd 以便字符串比较器工作,但我不希望为了可读性而呈现该格式。我还需要该列可由用户动态排序,因此服务器端排序也无法帮助我。预先感谢您的任何帮助。
所以我完全复制了ACE的"入门"代码,然后尝试添加标记.我从ACE的网站复制了语法,这与推荐的相同: 如何用Ace突出显示多行?
我得到的只是控制台中的一个错误,说Undefined不是一个函数.
我的目标是添加标记,以便突出显示一行文本.任何想法为什么这不起作用?
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
editor.getSession().addMarker(new Range(1,0,1,200),"ace_active_line","background");
Run Code Online (Sandbox Code Playgroud) 我正在使用Scroll Magic JS.我的目标是使用我的HTML5视频(下面)并使用pin方法使其粘贴在背景中,同时文本滚动到它的顶部.
<video preload="auto" autoplay="autoplay" loop="loop" id="bgvid">
<source src="../../pictures/coding.mp4" type="video/mp4">
</video>
Run Code Online (Sandbox Code Playgroud)
我的Javascript:
var scene_statement = new ScrollScene({triggerElement: "#trigger5", duration: 400})
.setPin("#bgvid")
.addTo(controller);
Run Code Online (Sandbox Code Playgroud)
当我不包含javascript时,视频完美运行(显然不会固定),当我在图像而不是视频上使用javascript时,固定效果非常好.
当我在视频中使用javascript时,视频仍会显示,并且它会固定,但它不会播放.有谁知道怎么克服这个?
谢谢
javascript ×5
ace-editor ×1
firebase ×1
google-api ×1
html ×1
html5 ×1
jquery ×1
material-ui ×1
react-hooks ×1
reactjs ×1
scroll ×1
scrollmagic ×1
sorting ×1
use-context ×1