1、简介

Vue ssr框架。支持vue2,vue-router,vuex,vue server render, vue meta

2、基本使用:

vue init nuxt-community/koa-template //基于koa2的安装

接着cnpm i

npm run dev开启服务

观察Nuxt.js目录:

pages入口页面组件

在page中的vue模板文件名称都是路径

创建完成后即可在相应路由处访问,无需手动配置路由

查看相应页面我们发现系统还自动配置了一行文字

来源于layouts中的模板文件,里面存放着公共的组件,比如说需要在所有路由下都显示的头部,尾部,侧边栏等

每新建一个组件,都会自动添加相应的组件

pages中的页面组件会放到layouts内模板组件中的nuxt标签内

自定义一个简单的layout模板

这样我们在pages下模板使用时在script标签下export default内声明

layout:'your layouts name'

nuxt.config.js是nuxtjs的配置文件,

可以配置全局的css文件

nuxt获取异步数据

server目录创建interface接口目录

目录下创建接口文件:

接着在server文件夹下入口文件index.js中引入

import name from '...'

同一文件下接着书写:

即可

接着可在模板文件中使用:

这里未配置ssr客户端渲染,是我们的页面在页面加载完后再向服务器发起请求:

为了实现在下发资源的同时进行渲染,我们修改:

这样会把数据和编译好的内容一并返回给浏览器

fetch主要用于处理vuex相关的数据

vuex结合使用nuxtjs

方法与单独使用nuxtjs类似

在路由index.js入口文件书写:

此时,vuex已经可以运行,如果不行,请重启服务。

也是实现了ssr

在此总结nuxt目录下各个子目录的作用

components:写页面组件

assets:存放图片或者其他静态资源文件

store 管理vuex状态

layouts 页面结构复用

pages  创建根路由

vue ssr 工作原理:

ssr解决seo的问题。可以使内容快速展现。‘

nuxt.js升级为

Nuts.js01的更多相关文章

  1. Timus 2068. Game of Nuts 解题报告

    1.题目描述: 2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still i ...

  2. ural 2068. Game of Nuts

    2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...

  3. [LintCode] Nuts & Bolts Problem 螺栓螺母问题

    Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping ...

  4. Lintcode399 Nuts & Bolts Problem solution 题解

    [题目描述] Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one m ...

  5. Lintcode: Nuts & Bolts Problem

    Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping ...

  6. How To Make A Swipeable Table View Cell With Actions – Without Going Nuts With Scroll Views

    How To Make A Swipeable Table View Cell With Actions – Without Going Nuts With Scroll Views  Ellen S ...

  7. UVA 10944 Nuts for nuts..

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=21&p ...

  8. Nuts & Bolts Problem

    Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping ...

  9. (转)Nuts and Bolts of Applying Deep Learning

    Kevin Zakka's Blog About Nuts and Bolts of Applying Deep Learning Sep 26, 2016 This weekend was very ...

随机推荐

  1. 【shell】概述

    功能简介 批量自动初始化系统(update,软件安装,时区设置,安全策略...) 批量自动部署软件(LAMP,LNMP,Nginx,LVS,Tomcat) 管理应用程序(KVM,集群管理扩容,MySQ ...

  2. Linux平台下_tomcat的安装与优化

    一.Tomcat介绍 Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选.对于一 ...

  3. iOS 有关二维码

    一.把相应的URL生成二维码 利用有关图像变成的框架 #import <CoreImage/CoreImage.h> 步骤:实例化二维码滤镜---->恢复滤镜属性---->将字 ...

  4. MVP简要示例

      MVP即Model-View-Presenter,是从经典的MVC演变而来的,它们的基本思想有相通的地方:Controller/Presenter负责逻辑的处理.Model提供数据.View负责显 ...

  5. OA项目-表结构

    ###############  新建APP并配置   ############### INSTALLED_APPS = [ ... 'apps.users.apps.UsersConfig', 'a ...

  6. Different Integers

    牛客一 J题 树状数组 题目描述 Given a sequence of integers a1, a2, ..., an and q pairs of integers (l1, r1), (l2, ...

  7. bug宝典linux篇 LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory(转)

    升级glibc库后,使用xShell登录linux,提示: Connecting to ... Connection established. To escape to local shell, pr ...

  8. deeplearning.ai 改善深层神经网络 week2 优化算法

    这一周的主题是优化算法. 1.  Mini-batch: 上一门课讨论的向量化的目的是去掉for循环加速优化计算,X = [x(1) x(2) x(3) ... x(m)],X的每一个列向量x(i)是 ...

  9. Spring+Mybais整合

    简单的来说,Spring主要用于在业务层(当然spring也有数据库交互的模块,个人觉得spring在这方面有一点不如mybatis),而mybatis主要用于数据持久化,在一个完整的项目中无论是业务 ...

  10. [LC] 225. Implement Stack using Queues

    Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. po ...