我有一个用 React Js 构建的网站,也在 Next Js 上构建了相同的网站。
我现在面临的问题是,与react-router-dom相比,nextJs中的路由器似乎非常慢,更改路由大约需要2-3秒。
以下是您可以通过浏览不同页面来感受性能差异的 URL。
https://cutt.ly/mhbPkOE (React Router Dom) 与 https://cutt.ly/BhbPvHv (NextJs)
我在 Github 上读到了一些评论,其中很少有专家说它将在生产中解决。但在生产中看起来也一样。
请看下面的代码
_app.jsx
// import App from 'next/app'
import React from "react"
import Router from 'next/router';
import "../static/sass/application.scss";
import "bootstrap/dist/css/bootstrap.min.css";
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
import 'semantic-ui-css/semantic.min.css'
import { wrapper } from "../../redux/utils/store"
import App from 'next/app';
// A simple component that we created
import {LoaderOverlay} from '../components/Reusable'
class MyApp extends App {
constructor(props){
super(props)
this.state = {
isLoading: false,
}
Router.onRouteChangeStart …Run Code Online (Sandbox Code Playgroud) 我的项目中有服务器端渲染的要求。所以,我已经使用下一个 js 开发了它,现在我在部署中获得了结构。
我需要在 iis 中部署我的项目,但不知道如何实现。我尝试了很多没有运气。它在开发模式下工作正常,但在生产模式下不工作。
我试过,next export但这是用于静态页面部署,我的项目使用动态页面。
任何帮助将不胜感激。提前致谢。
我正在尝试将我的 NEXTJS 应用程序部署到 azure。我创建了一个包含安装了 Node 的 linux 操作系统的 web 应用程序。我的package.json看起来像这样。
{
"name": "frontend",
"version": "1.0.0",
"description": "This package contains all necessary depenencies for frontned",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start -p $PORT",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "masnad",
"license": "ISC",
"dependencies": {
"@zeit/next-css": "^1.0.1",
"next": "^8.0.3",
"react": "^16.8.3",
"react-dom": "^16.8.3"
}
}
Run Code Online (Sandbox Code Playgroud)
我首先创建了一个空的 web 应用程序,然后使用了部署服务 kudu,我将我的代码从本地推送到了 azure。
推送到 azure 时的 git 日志如下所示
remote: ..............................................................
remote: npm …Run Code Online (Sandbox Code Playgroud) 经过大量研究,关注 YouTube 视频https://youtu.be/Ny5vJRfQito并将支付网关部署到 Azure。
但是,在付款时,遇到以下问题,说明没有找到 payment_intent.js
以下是存储库中可用文件的屏幕截图
借助URL https://myapp.scm.azurewebsites.net/DebugConsole/?shell=powershell导航到Azure App Service,发现文件不在列表中,如下图
谷歌搜索了很多,但找不到解决方案。
如果这里有人可以帮助我在 Azure 上进行部署以及需要采取哪些其他步骤来解决问题,我将不胜感激。
如果需要任何其他详细信息,请告诉我
提前致谢
更新
这是一个 Next.js 应用程序,最终的项目文件存储在OUT文件夹中,因为 next.js 没有构建文件夹,如下所示。同样的文件也显示在 www 根目录下。
代码在 localhost 上运行良好,以下是完整的文件夹结构
下面是构建管道的屏幕截图
下面是out文件夹
next.js ×3
azure ×2
javascript ×2
reactjs ×2
azure-devops ×1
deployment ×1
iis ×1
next-router ×1
node.js ×1