小编mat*_*twg的帖子

nextjs 使用 Link 组件重新加载页面

我有一个简单的nextjs 13应用程序 ( appDir ),有 2 个页面和一个<Link/>组件导航。

  • 第一页Home- 静态
  • 第二页Test- 在服务器端从第三方源接收动态随机内容(获取)。

问题:当应用程序呈现时,一切正常,但是当我尝试在页面之间切换时,我的测试页面显示旧内容,我可以刷新浏览器以获取实际数据,与通过常规链接导航非常相似,但是<a/>我无需重新加载整个应用程序。

Q:使用组件切换页面时如何强制nextjs 13重新加载页面?Test<Link/>

// src/components/navbar.tsx

'use client'

import {usePathname} from "next/navigation";
import Link from "next/link";

const navItems = [
    {text: 'Home', href: '/'},
    {text: 'Test', href: '/test'}
];

const Navbar = () => {
    const pathname = usePathname();

    return <nav className="nav nav-masthead justify-content-center float-md-end">
        {navItems.map((item: { text: string, href: string, link?: boolean }, idx: number) …
Run Code Online (Sandbox Code Playgroud)

next.js next.js13

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

Nodejs RangeError:指定的时区无效

我有测试示例:

console.log("test");

const t = new Date().toLocaleString("en-US", {
  timeZone: "+0000"
});

console.log(t);
Run Code Online (Sandbox Code Playgroud)

Google Chrome 122.0.6182.0(官方版本)开发版(64 位) Chrome浏览器

或者尝试: https: //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#try_it

在浏览器控制台中 - 好的,但在 Nodejs 中 - 错误

test

/home/jdoodle.js:3
const t = new Date().toLocaleString("en-US", {
                     ^

RangeError: Invalid time zone specified: +0000
    at Date.toLocaleString (<anonymous>)
    at Object.<anonymous> (/home/jdoodle.js:3:22)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v21.2.0
Run Code Online (Sandbox Code Playgroud)

示例: https: //www.jdoodle.com/ia/T3V

谁能向我解释为什么它不起作用以及如何使它起作用?

javascript node.js typescript

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

c++ 警告:Clang-Tidy:条件链中的重复分支

你能帮我如何避免这段代码中的警告...

警告:Clang-Tidy:条件链中的重复分支

HubInterface *getFreeHub() {
        HubInterface *freeHub = nullptr;
        while (freeHub == nullptr) {
            for (auto hub : this->getHubList()) {
                if (freeHub == nullptr) {
                    freeHub = hub;
                } else if (hub->getStatus() == STATUS_READY &&
                           hub->getBusyNodes().size() < freeHub->getBusyNodes().size()) {
                    freeHub = hub;
                }
            }
            sleep(5);
        }
        return freeHub;
    }
Run Code Online (Sandbox Code Playgroud)

CLion IDE 提供的警告

c++ c++14 clion

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

标签 统计

c++ ×1

c++14 ×1

clion ×1

javascript ×1

next.js ×1

next.js13 ×1

node.js ×1

typescript ×1