我无法正确运行RSS Feed的日期.你知道它的正确日期是什么吗?
我把它存储在一个名为creation_date的字段中,格式为:2012-08-14 10:17:12
然后我抓住它:
$pubDate = $article[creation_date];
Run Code Online (Sandbox Code Playgroud)
然后我转换它:
$pubDate= date("Y-m-d", strtotime($pubDate));
Run Code Online (Sandbox Code Playgroud)
然后在我的商品标签中我放置它:
<pubdate>'.date("l, F d, Y", strtotime($pubDate)).'</pubdate>
有没有我没见过的东西?
通常,在使用 Express 时,“res”对象中似乎有“cookie”,因此您可以执行以下操作:
res.cookie('session', sessionCookie, options);
Run Code Online (Sandbox Code Playgroud)
NextJS 在 Next 9 提供的 API 路由中,查看 res 的时候,是不存在的。有没有办法在 Next API Route 函数中为响应对象设置 cookie?
我刚刚升级到 React Native 0.67.3,现在当我打开使用 React Navigation v6 的应用程序时,我收到此错误:
Occurred in worklet location: /Users/path/node_modules/react-native-reanimated/lib/reanimated2/hook/useAnimatedStyle.js (332:24)
Possible solutions are:
a) If you want to synchronously execute this method, mark it as a Worklet
b) If you want to execute this method on the JS thread, wrap it using runOnJS
2022-03-09 10:54:14.180294-0500 project[1949:15686] [native] Tried to synchronously call anonymous function from a different thread.
Occurred in worklet location: /Users/path/node_modules/react-native-reanimated/lib/reanimated2/hook/useAnimatedStyle.js (332:24)
Run Code Online (Sandbox Code Playgroud)
我目前正在使用 DrawerNavigator,如下所示:
<Drawer.Navigator initialRouteName="Home" >
<Drawer.Screen name="HomeStack" component={HomeStack} />
</Drawer.Navigator>
Run Code Online (Sandbox Code Playgroud)
以下是我的相关软件包的版本:
"react-native-reanimated": "2.3.1", …Run Code Online (Sandbox Code Playgroud) 当我调用 withRouter 时,我能够在数据第二次呈现时看到输出。
我的组件如下所示:
const Home = (props) => {
console.log("all props", props)
let { router } = props
let { category, item } = router.query
console.log("Cat", category)
console.log("Item", item)
return (
<FirebaseContext.Provider value={new Firebase()}>
<div>
<Head>
<title>Category</title>
</Head>
<Navigation />
{/* <Item category={category} item={item} {...props} /> */}
</div>
</FirebaseContext.Provider>
)
}
Home.getInitialProps = async (props) => {
console.log(props)
return { req, query }
}
export default compose(withRouter, withAuthentication)(Home)
Run Code Online (Sandbox Code Playgroud)
如果你看控制台,第一个渲染看起来像:
asPath: "/c/cigars/1231"
back: ƒ ()
beforePopState: ƒ ()
events: {on: …Run Code Online (Sandbox Code Playgroud) 我正在使用 Router(Page) 调用页面,并期望该页面的变量(该页面称为 [category].js)出现在初始页面加载时。查询本身在那里,键在那里,但值是“未定义”。服务器端似乎有一些对 getInitialProps 的调用,其中 2/3 未定义。
React组件有构造函数等,它不是函数式组件。
这是我当前的 getInitialProps:
Category.getInitialProps = async ({ req, query }) => {
let authUser = req && req.session && req.session.authUser
let categoryData = {}
let categoryItemData = {}
let category = query.category
if(category){
let res = await fetch(url1,
{
method: 'POST',
credentials: 'include',
})
categoryData = await res.json();
let categoryItemsRes = await fetch(url2,
{
method: 'POST',
credentials: 'include',
})
categoryItemData = await categoryItemsRes.json();
}
return { query, authUser, categoryData, categoryItemData }
}
Run Code Online (Sandbox Code Playgroud) 我试图在图像上放置一个div,使其像一个标题,直接在图像的顶部.
有时标题比其他时间更长,因此我无法设置特定的margin-top:-px,因为有时标题的高度更长.
我试过这个并且链接的背景(黑色)没有显示,也像我刚才所说的,标题高度改变所以这个方法是垃圾:
<div>
<img src = "<? echo $image_url ?>" style="float:left;min-width:220px;max-width:220px;">
<a href="LINK" ><div style="width:210px;background-color:black;color:white;bottom:0;margin-top:-20px;padding-left:10px;padding-top:10px;font-size:16px;"><? echo $title ?></div></a>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何编写像Reddit.com这样的网站算法,其中有数千个帖子需要排名.他们的排名算法就像这样(你不必阅读它,它更像是我的一般性问题):http://amix.dk/blog/post/19588
现在我有一个存储在数据库中的帖子,我记录他们的日期,他们每个都有一个upvotes和downvotes字段,所以我存储他们的记录.我想知道你如何存储他们的排名?当特定帖子具有排名值,但它们随时间变化时,您如何存储其排名?
如果它们没有存储,那么每次用户加载页面时,您是否对每个帖子进行排名?
你什么时候存储帖子?你是否运行一个cron作业来每隔x分钟自动为每个帖子提供一个新值?你存储它们的价值吗?这是暂时的.也许,直到那篇文章达到最低分并被遗忘?
我不确定你怎么称呼这种类型的模态,但 iOS 上流行的一种模态并不能完全全屏显示,也许距顶部有 10% 的边距。这是一张图片:
这是我的标准模态设置:
<Modal visible={imageViewerVisible} transparent={true} onRequestClose={() => this.setImageViewerVisible(false)} style={{ backgroundColor: 'black'}}>
<ImageViewer imageUrls={ images } index={0} onSwipeDown={() => this.setImageViewerVisible(false) } enableSwipeDown={true} />
</Modal>
Run Code Online (Sandbox Code Playgroud)
我不确定是否有我可以使用的道具,或者它可能不是本机反应本机模式?甚至不知道人们如何称呼这种类型的模态!提前致谢。
我正在考虑将 Firestore 用于社交媒体提要的几个想法。到目前为止,我的想法还没有实现,所以对于这个想法,我希望得到社区的反馈。
这个想法是允许用户发布信息,或记录他们的活动,并向任何关注/订阅该信息的用户显示它。帖子信息将位于名为posts.
据我所知,这些方法需要的读取和写入次数大致相同。
一个想法是在users/{userId}有一个名为 posts 的字段中,它是一个我有兴趣为用户提取的 documentIds 数组。这将允许我直接从数据中提取posts并获取最新版本的数据。
另一种方法似乎更像是 Firebasey,它是将文档存储在 users/{userId}/feeds 中,这些文档是帖子本身的副本。我可以使用相同postID的数据posts。据推测,如果我需要为任何评论更新数据,我可以使用组集合查询来获取所有称为提要的集合,其中 docID 是相等的(或者只是创建一个字段来执行适当的操作"where", "==", docId)。
第三种方法是更新应该查看帖子的人员列表。只要帖子列表比关注者列表短,这似乎更好。您不是在每个关注者上维护所有帖子,而是在每个帖子上维护所有关注者。对于每个新关注者,您都需要更新所有帖子。
此列表不会是用户自己的帖子。相反,它将是显示该用户的所有帖子的列表。
三个挑战者:
users/{userId} 与字段称为feed- 指向全局帖子的文档 ID 数组。获取该提要,通过 ID 获取所有文档。每次用户有活动时,都需要为每个关注者更新每个数组。
users (coll)
-> uid (doc)
-> uid.feed: postId1, postId2, postId3, ...] (field)
posts (coll)
-> postId (doc)
Run Code Online (Sandbox Code Playgroud)查询(伪):
doc(users/{uid}).get(doc)
feed = doc.feed
for postId in feed:
doc(posts/{postId}).get(doc)
Run Code Online (Sandbox Code Playgroud)
users/{userId}/feed 其中包含posts您希望该用户看到的所有内容的副本。每个活动/帖子都需要添加到每个相关的提要列表中。
users (coll)
-> uid (doc)
-> feed: …Run Code Online (Sandbox Code Playgroud)我正在拨打电话,返回问题及其答案。当我直接向服务器发送此消息时,响应符合预期。此外,当 React 进行调用并且我检查开发人员工具时,响应符合预期。
一旦我收到阿波罗的回应,数据就变得混杂,结果也相互渗透。
您会注意到,在这两张图中,扩展一些结果后的结果是相同的。我不确定是什么原因造成的。
为什么要结合自由形式?
我的设置是这样的:
我导入查询,然后在 Apollo 客户端上运行:
this.props.client.query({ query: getCoreObjectsQuery, variables: { companyId: 1}})
.then((result) => {
console.log(result, 'getCoreObjectsQuery')
Run Code Online (Sandbox Code Playgroud)
从那里,当我查看 getCoreObjectsQuery 时,它看起来像上面的图像!
是否可以在MySQL结构中创建一个自动对另外两列进行求和的列?
所以,如果我有一个名为的表TABLE:
Column A, Column B, and Column C.
Run Code Online (Sandbox Code Playgroud)
我想Column C自动总结Column A和Column B.
那可能吗?
如果A改变,则C改变.
我正在尝试实施此处概述的规则:https : //stackoverflow.com/a/56047977/1604072
match /{path=**}/posts/{post} {
allow read: if request.auth.uid != null;
}
Run Code Online (Sandbox Code Playgroud)
这会产生此错误:无效的 glob 匹配表达式。全局匹配被允许作为匹配声明路径中的最后一段。
这是现在写这个的唯一/正确的方法吗?:
match /{path=**}{
match /collectionItems/{collectionItem} {
allow read: if request.auth.uid != null;
}
}
Run Code Online (Sandbox Code Playgroud) 我想将一个字符串插入另一个字符串.
我有youtube链接:http: //www.youtube.com/9bZkp7q19f0
我想在.com之后添加/嵌入,以便我可以动态地嵌入它们.
我怎样才能让它们看起来像这样?:http: //www.youtube.com/embed/9bZkp7q19f0
next.js ×3
php ×3
reactjs ×3
javascript ×2
mysql ×2
react-native ×2
algorithm ×1
apollo ×1
css ×1
embed ×1
firebase ×1
graphql ×1
html ×1
modal-dialog ×1
node.js ×1
react-apollo ×1
rss ×1
youtube ×1