在使用 Google Mobile 进行测试时,我的网站不适合移动设备。但实际上,在访问它时,它是移动友好的。
我应该做什么来修复它?我正在使用 Next.js。
我测试时的结果:https://search.google.com/test/mobile-Friendly/result ?id=zwleJJ0VXRiIwFagHtBHuA
我的package.json:
{
"name": "tintuc",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 8080",
"build": "next build",
"start": "next start -p 8080",
"sitemap": "next-sitemap",
"analyze": "cross-env ANALYZE=true next build",
"analyze:server": "cross-env BUNDLE_ANALYZE=server next build",
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build",
"find:unused": "next-unused",
"depcheck": "npx depcheck"
},
"dependencies": {
"@apollo/client": "^3.3.19",
"@headlessui/react": "^1.4.1",
"@heroicons/react": "^1.0.4",
"date-fns": "^2.25.0",
"deepmerge": "^4.2.2",
"graphql": "^15.5.0",
"highlight.js": "^11.6.0",
"html-react-parser": "^3.0.4",
"lodash": "^4.17.21",
"next": "^12.2.5",
"next-seo": …Run Code Online (Sandbox Code Playgroud) 我是相当新的使用algorithm和functionalC++中.我需要进行树遍历并为每个元素执行一个函数.请参阅下面的代码.
这有效,但我有一些我不喜欢的事情,或许可以做得更好.请注意,我仅限于相当旧版本的g ++(4.4.7),并且不能使用lambda函数.
我使用包装函数do_walk并在每个元素上std::bind调用成员函数walk.有没有办法避免包装函数并直接调用成员函数?
我使用typedef作为回调函数UnaryFunction.我更喜欢使用模板版本walk.但是,当我更改代码以使用模板时,我得到以下编译错误:error: no matching function for call to 'bind(<unresolved overloaded function type>, std::_Placeholder<1>&, void (*&)(const Elem&))'.是否可以在此上下文中使用模板?
也许有一种替代方案std::for_each更适合这种树遍历?
我的代码到目前为止:
#include <list>
#include <algorithm>
#include <functional>
struct Elem;
typedef void (*UnaryFunction)(const Elem&); // (2)
struct Elem
{
std::list<Elem> children; // Some container, std::list for now.
//template< class UnaryFunction > // (2)
void walk(UnaryFunction f) const
{
// Walk all children.
std::for_each( …Run Code Online (Sandbox Code Playgroud) 我有一个具有多种功能的网络应用程序,例如私人消息、购买、优惠等。我想让它实时工作,所以我决定使用 socket.io。我使用 redux 进行全局状态管理,但我不知道如何将其与 socket.IO 结合起来。这是我的想法:
1.创建一个用于套接字处理的文件,并使用导出到 App.js 的函数来创建套接字连接,发送和侦听不同的数据。
2.每当我收到相关信息(例如通知或购买请求)时,我都会更新我的 redux 状态。
3.最后,在我的组件中,我将使用 useEffect 来处理这些全局 redux 状态,如果它发生变化,我将根据更改后的状态重新渲染我的组件。
这是一个好方法吗?如果不是,哪种是根据套接字收到的信息全局管理我的组件的正确方法?