小编Afs*_*fda的帖子

Nextjs 如何将多个路由映射到一个页面?

我的版本 9 中有一个名为blog的页面nextjs

Next为我的页面创建一个路由/博客。现在我想让这些路由映射到同一个博客页面,从而映射到博客组件:

1. /blog/cat1/gold
2. /blog/cat2/silver
3. /blog/cat3/bronze
Run Code Online (Sandbox Code Playgroud)

实际上,我想query parameters在路线中使用它们,但我不想遵循以下格式:

1. /blog?cat=cat1&color=gold
2. /blog?cat=cat2&color=silver
3. /blog?cat=cat3&color=bronze
Run Code Online (Sandbox Code Playgroud)

我使用过,next/router asPath但它完全是客户端,通过重新加载它返回404

nextjs 9动态路由中提供了这可能对我有帮助,但问题是我只想拥有一个组件和不同的路由。

你有什么想法?

routing query-parameters reactjs react-router next.js

13
推荐指数
1
解决办法
5100
查看次数

此请求缺少有效的应用程序标识符,这意味着安全网检查和 reCAPTCHA 检查均未成功

Flutter 应用 Firebase 电话身份验证错误:

此请求缺少有效的应用程序标识符,这意味着安全网检查和 reCAPTCHA 检查均未成功。

请帮我解决这个问题。

在此处输入图片说明

mobile flutter

11
推荐指数
4
解决办法
7682
查看次数

Nextjs- api 路由,如何从标头中删除 cookie?

我有两个 API 路由,我想在其中设置两个 cookie/api/login.js并在/api/logout.js.

这是我的登录 API:

import { serialize } from 'cookie';

export default async (req, res) => {
  res.setHeader('Set-Cookie', [
    serialize('mytoken1', 'mytoken1Value', {
      path: '/',
    }),
    serialize('mytoken2', 'mytoken2Value', {
      path: '/',
    }),
  ]);

  res.writeHead(302, { Location: '/' });
  res.end();
}
Run Code Online (Sandbox Code Playgroud)

这是我的注销 API:

export default async (req, res) => {
  res.removeHeader('Set-Cookie')

  res.writeHead(302, { Location: '/api/login' });
  res.end();
}
Run Code Online (Sandbox Code Playgroud)

但注销不会删除 cookie,因此当我重新加载页面时,我仍然可以在_app.js ---console.log(req.headers.cookie)--- 中看到它们。您知道在这种情况下如何删除 cookie 吗?

cookies node.js express next.js

10
推荐指数
3
解决办法
3万
查看次数

Expo 应用程序 - 无法加载带有消息的项目:这比它应该花费的时间要长得多

我以这种方式构建我的本机应用程序:

1.npm install expo-cli --global .

2.expo init my-new-project .

3.cd my-new-project and expo start --lan .

4. install expo on my ios device .

5.打开Expo,然后点击“扫描二维码”并在我们的终端中扫描二维码。

但我收到以下错误:

错误

我在两台设备上都连接到相同的 wifi 并且我的 IP 是相同的。我关闭了我的 Windows 防火墙。

你知道为什么会这样吗?我曾经在手机上看到过输出,但此后每次都会出现此错误。

react-native expo

9
推荐指数
3
解决办法
6408
查看次数

Hyperledger Fabric gRPC 交互

我一直在摆弄gRPC,我正在考虑用 Rust构建我自己的简单而全面的hyperledger织物。SDK

我到处寻找结构gRPC的任何规范hyperledger,看看我们如何重现与对等点交互的功能,例如管理通道以及执行调用和查询之类的功能。

(重现此行为:https://hyperledger-fabric.readthedocs.io/en/release-1.4/commands/peerchannel.html)。

在网上,每个人都说该功能已通过 公开gRPC,但他们建议使用现有的 SDK。

我检查nodeJS SDK并查找了他们的 .proto 文件,但几乎没有任何服务(https://github.com/hyperledger/fabric-sdk-node/tree/release-1.4/fabric-client/lib/protos

有什么办法可以得到他们的gRPC规格吗?有没有一种通用的方法可以为服务器做到这一点gRPC?为何如此隐藏?

谢谢!

grpc hyperledger hyperledger-fabric

6
推荐指数
1
解决办法
1329
查看次数

React 设置状态不会在获取成功函数中更新(在按键事件上)

我有一个component包含一个输入的搜索,我定义了一个key up event handler function用于根据输入的字符串获取数据的输入。正如你在下面看到的:

class SearchBox extends Component {
    constructor(props) {
        super(props);
        this.state = {
            timeout: 0,
            query: "",
            response: "",
            error: ""
        }
        this.doneTypingSearch = this.doneTypingSearch.bind(this);
    }
    doneTypingSearch(evt){
        var query = evt.target.value; 
        if(this.state.timeout) clearTimeout(this.state.timeout);
        this.state.timeout = setTimeout(() => {
            fetch('https://jsonplaceholder.typicode.com/todos/1/?name=query' , {
                method: "GET"
            })
            .then( response => response.json() )
            .then(function(json) {
                console.log(json,"successss") 
                //Object { userId: 1, id: 1, title: "delectus aut autem", completed: false }  successss

                this.setState({
                    query: query,
                    response: json
                })
                console.log(this.state.query …
Run Code Online (Sandbox Code Playgroud)

javascript fetch setstate reactjs

5
推荐指数
1
解决办法
3381
查看次数

在 ssr 时使用动态路由时未找到 Nextjs 资产 404

我有一个旧版本的静态文件夹nextjs。我更新了我nextjs的使用public文件夹。

"next": "^9.4.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
Run Code Online (Sandbox Code Playgroud)

这是我的nextjs配置:

const withPlugins = require('next-compose-plugins');
const withCss = require('@zeit/next-css');
const withSass = require('@zeit/next-sass');
const withImages = require('next-images');
require('dotenv').config();
const withSourceMaps = require('@zeit/next-source-maps')();

if (typeof require !== 'undefined') {
  // eslint-disable-next-line no-unused-vars
  require.extensions['.css'] = file => {};
}

const nextConfig = {
  env: {
    BUILD_ENV: process.env.BUILD_ENV,
  },
  webpack: (config, { isServer }) => {
    if (!isServer) {
      // eslint-disable-next-line no-param-reassign
      config.resolve.alias['@sentry/node'] = '@sentry/browser';
    }

    if (isServer) …
Run Code Online (Sandbox Code Playgroud)

assets reactjs server-side-rendering next.js dynamic-routing

5
推荐指数
1
解决办法
2539
查看次数

打字稿,样式组件错误:TS2769:没有重载与此调用匹配。过载 1 个(共 2 个)

这是我的 styledComponent:

\n
const stopPropagation = (event: Event): void => {\n  event.stopPropagation();\n};\n\n<StyledComp onClick={stopPropagation}> //error occurs here\n    hi StyledComp\n</StyledComp>\n
Run Code Online (Sandbox Code Playgroud)\n

这就是我的定义:

\n
export type Prop = {\n  onClick: (event: Event) => void;\n};\n\nexport const StyledComp = styled.div<Prop>`\n  display: flex;\n`;\n
Run Code Online (Sandbox Code Playgroud)\n

但它返回一个错误,例如:

\n
\n

TS2769:没有与此调用匹配的重载。\xc2\xa0\xc2\xa0Overload 1 of 2, \'(props: Pick<Pick<Pick<DetailedHTMLProps<HTMLAttributes, HTMLDivElement>, "title" | "slot" | ... 252 更多 ... | "is" > & { ...; } & StyledComp, "标题" | ... 254 个以上 ... | "is"> & Partial<...>, "标题" | ... 254 个以上 …

typescript reactjs styled-components

5
推荐指数
1
解决办法
6964
查看次数

元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:符号

我正在尝试lazy Loading用于我的应用程序。

索引.js

import React, { Suspense , lazy , Component } from 'react';
import ReactDOM from 'react-dom';
import 'index.scss';
import SomeComponent from './someComponent.js';
import * as serviceWorker from 'serviceWorker';

ReactDOM.render(<SomeComponent />, document.getElementById('root'));
serviceWorker.unregister();
Run Code Online (Sandbox Code Playgroud)

一些组件 index.js 文件

import React, { Suspense , lazy , Component } from 'react';
import { BrowserRouter } from 'react-router-dom';
const Header = lazy(() => import('./_header'));

class SomeComponent extends Component {
  render() {
    return (
      <BrowserRouter>
          <React.Fragment>
            <Suspense>
              <Header />
            </Suspense>
          </React.Fragment>
      </BrowserRouter>
    ); …
Run Code Online (Sandbox Code Playgroud)

lazy-loading reactjs webpack

4
推荐指数
1
解决办法
1957
查看次数

如何使用Wicked PDF自动打印生成的PDF?

我正在使用Wicked PDF,并且在单击按钮时在新选项卡中生成了pdf。但是我想通过单击按钮自动打印pdf 。我添加了这个print_media_type并将值设置为true,我希望我的打印机选项可以开始工作,但是什么也不会发生!有什么想法吗?

respond_to do |format|
        format.html
        format.pdf do
          render pdf: "file_name", :template => 'officials/individual_receipt_export.html.erb', encoding: 'utf8',page_size: 'A4',:print_media_type => true
        end
end
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails wicked-pdf

2
推荐指数
1
解决办法
2063
查看次数