当前位置:网站首页>Online Excel based on Next.js
Online Excel based on Next.js
2022-08-04 15:07:00 【51CTO】
If you want to start from scratch React 构建一个完整的 Web 应用程序,需要哪些步骤?
It's certainly not as simple as putting an elephant in the fridge,Just divide it into three steps:打开冰箱,拿起大象,Just put it in the fridge.
There are many details we need to consider,比如:
- A packer must be used(例如 webpack)打包代码,并使用 Babel Wait for the compiler to convert the code.
- It needs to be optimized for production environments,例如代码拆分.
- Some pages need to be pre-rendered to improve page performance and performance SEO,Might also want to use server-side rendering or client-side rendering.
- Some server-side code has to be written to get the React The application connects to the data store.
These issues are all we need to pay attention to,但是Next.js的出现,完美地解决了这些问题,You can get them all with one frame.
Next.jsThe framework has the right level of abstraction and is great“开发人员体验”,包括静态及服务器端融合渲染、 支持 TypeScript、智能化打包、 路由预取等功能,无需任何配置,开箱即用,These are things that development teams have when they write code“Serve with chocolate on a rainy day”A generally silky experience.
认识 Next.js
Next.js是一款React 开发框架,It helps us build React 应用程序.作为一个轻量级React服务端渲染应用框架,It has many built-in functions,包括不仅限于:
- 直观的、 基于页面的路由系统(并支持动态路由)
- 预渲染——支持在页面级的 静态生成 (SSG) 和 服务器端渲染 (SSR)
- 自动代码拆分,提升页面加载速度
- Client-side routing with optimized prefetching
- 内置 CSS 和 Sass 的支持,并支持任何 CSS-in-JS 库
- The development environment supports fast refresh
- 利用 Serverless Functions 及 API 路由 构建 API 功能
- 完全可扩展
当前,Next.js is being used by tens of thousands of websites and Web 应用程序,Including many world-renowned well-known companies and head brands.可以说,Its visible ease of use has firmly captured the hearts of users,Whether it is for enterprise users or small and micro developers,From basic framework to release operation and maintenance,It all provides corresponding solutions.
接下来,We'll take everyone based on thatNext.js实现类ExcelThe online form editing function of the control.
实战之旅
首先需要安装Node.js,并且Node.js版本需要高于10.13,
You can refer to the installation process: https://nodejs.org/en/
安装完成后,就可以创建Next.js应用.
打开终端窗口,Go to the program directory where the application was created,然后执行以下命令:
安装完成后执行npm run dev
,If the project can start normally,It means that the project has been created normally,The project created by default will start at3000端口,展示如下:
The item can then be movedpages下的index.jsSome unnecessary content elements are removed,Load the class we wrote next under the project pathExcel表格控件.
最终展示效果如图:
The red area is the main body of the table,The upper toolbar is the online form editor.在实际项目中,We can introduce component runtimes individually,You can also import all the online form editing areas(The online table editor will have a runtime associated with it).
首先,我们需要在package.json中加入如下依赖:
接下来,我们在项目根目录下新建components文件夹,并创建OnlineDesigner.js文件,在该文件中,我们引入spreadjs相关资源,And introduce the component runtime.详细代码如下所示:
创建完成之后,我们需要在pages目录下的index.jsIntroduce defined components.这里要注意的时,Don't use server-side rendering when importing components(SSR),will appeardocument undefined的错误,这种错误,一般和nodejs无法操作dom对象有关,The specific introduction method is:
执行npm run dev,显示效果如下:
接下来.我们需要继续在components文件夹下新建一个OnlineDesigner.js,Introduce online form editor:
编写完成之后,在index.jsIntegration can be introduced in:
执行npm run dev,显示效果如下:
Here we have successfully completed the basisNext.jsRealize online form editing function.
The example in this article gets the address: https://gitee.com/GrapeCity/nextjs-spreadjs
If you are interested in more application examples,可以查看:
https://demo.grapecity.com.cn/spreadjs/gc-sjs-samples/index.html
边栏推荐
猜你喜欢
随机推荐
Cisco-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
宣传海报
Technology sharing | Description of the electronic fence function in the integrated dispatching system
X-ray grazing incidence focusing mirror
leetcode:255 验证前序遍历序列二叉搜索树
JCMsuite应用:倾斜平面波传播透过光阑的传输
leetcode: 241. Designing precedence for arithmetic expressions
7 天能找到 Go 工作吗?学学 Go 数组和指针试试
【Web技术】1401- 图解 Canvas 入门
【Today in History】August 4: First female Turing Award winner; NVIDIA acquires MediaQ; first Cybersecurity Challenge completed
C# 局部函数与事件
【历史上的今天】8 月 4 日:第一位图灵奖女性得主;NVIDIA 收购 MediaQ;首届网络安全挑战大赛完成
企业级优化
动态数组底层是如何实现的
基于 Next.js实现在线Excel
leetcode: 255 Verify preorder traversal sequence binary search tree
【剑指offer59】队列的最大值
普法教育结合VR全景,直观感受和学习法治精神
【北亚数据恢复】IBM System Storage存储lvm信息丢失数据恢复方案
剑指Offer 63.股票的最大利润