小编Den*_*310的帖子

检查项目基于哪个 NextJs 版本

我正在开发 NextJs 项目,我想知道安装了哪个 NextJs 版本。我可以在哪里检查?

version command-line-interface reactjs package.json next.js

18
推荐指数
2
解决办法
4万
查看次数

ReactJs/NextJS - 5秒后自动重定向到另一个页面

  • 我正在创建欢迎页面,该页面应在客户登录后立即显示,并且该页面应在 5 秒后自动将客户重定向到另一个页面。我尝试使用默认值 5 秒的 setState,然后使用 1000 毫秒的 setInterval,将其减少 1,当达到 0 时,重定向客户。

Console.log() 总是返回 5,所以基本上在前端我总是看到这句话:欢迎,您已成功登录,您将被重定向到.. 4

看起来因为 setRedirectSeconds() 是异步的,所以它目前不会更新状态,并且每当我的 setInterval 函数再次启动时,redirectSeconds 每次仍将是 5。

如何解决这个问题?

这是我的代码:

const Welcome: NextPage = (): ReactElement => {
const [redirectSeconds, setRedirectSeconds] = useState<number>(5);
const router = useRouter();
const query = router.query;

useEffect(() => {
    if (query?.redirect) {
        setTimeout(() => {
            const interval = setInterval(() => {
                console.log(redirectSeconds);
                if (redirectSeconds > 0) {
                    setRedirectSeconds(redirectSeconds - 1);
                } else {
                    clearInterval(interval);
                    router.push(query.redirect.toString());
                }
            }, 1000)
        }, …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js

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

Ubuntu 18 上的 PhpStorm - 只读状态(无法更改文件)

当我在 Ubuntu 18 上使用 PhpStorm 打开项目时,当我尝试编辑文件时,会出现弹出窗口“清除只读状态”,并带有选项“清除 - 确定”。

当我单击清除时,再次出现弹出窗口,其中显示文本“无法更改以下文件的只读状态:...”

我无法在 Ubuntu 上更改克隆存储库(我通过 PhpStorm 访问的存储库)中的权限,因为文件权限将与在线存储库上的文件权限不同。

我可以使用 cli 通过 cli 编辑和写入文件sudo nano ..

phpstorm ubuntu-18.04

3
推荐指数
1
解决办法
5424
查看次数

Laravel 5.6: Customise a paginated resource collection meta and links attributes

How can I customize Laravel ResourceCollection meta and links information.

Links should include only prev,next and self instead of first,last,prev,next that is by default.

Meta should include pagination iformation like: current_page, total_items, items_per_page, total_pages instead of current_page, from, last_page, path, per_page, to, total.

This is how meta and links information looks now in JSON response:

"meta": {
    "currentPage": 2,
    "current_page": 1,
    "from": 1,
    "last_page": 3,
    "path": "http://localhost:8000/api",
    "per_page": 5,
    "to": 5,
    "total": 14
},
"links": {
    "self": "http://localhost:8000/api",
    "first": "http://localhost:8000/api?page=1", …
Run Code Online (Sandbox Code Playgroud)

php laravel eloquent laravel-5.6 laravel-resource

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