Vue 建立 Nuxt 项目 SSR 服务器渲染 解决 SPA 单页面 SEO优化 问题 (详细教程)

Vue SSR 服务器渲染 解决 SPA 单页面 SEO优化 问题

构建步骤

1. 建立nuxt 项目

检查 npxjavascript

// npm 5.2.0 以上版本默认包含 npx 
    // 建立项目
    npx create-nuxt-app project_name

Choose the package manager Yarn 须要安装 yarn 安装 yarnjava

yarn 下载typescript

配置参考npm

image.png

配置详解服务器

? Project name nuxttest                            //项目名称
? Project description My astounding Nuxt.js project        //项目描述
? Author name forever                                    //做者姓名
? Choose programming language JavaScript            //选择开发的语言 javascript or typescript
? Choose the package manager Yarn                //选择包管理的工具 npm or yarn
? Choose UI framework Element                    //选择一个UI框架
? Choose custom server framework Express            //选择一种服务端框架
? Choose Nuxt.js modules (Press <space> to select, <a> to toggle all, <i> to invert selection)
? Choose linting tools (Press <space> to select, <a> to toggle all, <i> to invert selection) //检查代码是否规范
? Choose test framework None                        //选择一个测试框架
? Choose rendering mode Universal (SSR)             //选择一种渲染模式 SSR or SPA
? Choose development tools (Press <space> to select, <a> to toggle all, <i> to invert selection)

运行

npm start

image.png

访问报错 NuxtServerError:Request failed with status code 500app

image.png

解决框架

//升级 npm 
npm install npm -g

从新运行工具

image.png

运行效果测试

image.png

目录结构

Nuxt.js

相关文章
相关标签/搜索