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. FactoryBean 和 BeanFactory

    大佬勿喷,如果有什么地方理解错了欢迎吐槽 一 .BeanFacory 首先来看看下边的代码 package com.lhf.beanfactory; public class SingleBean { ...

  2. [USACO09MAR]Moon哞哞叫Moon Mooing(模拟)

    链接:https://ac.nowcoder.com/acm/contest/1086/F来源:牛客网 题目描述 A full moon casts some sort of spell on the ...

  3. idea 项目 版本控制文件

  4. 一个搜索框的小demo

    一.实时按照输入的搜索值显示与其匹配的内容,隐藏其它内容 <%@ Page Language="C#" AutoEventWireup="true" Co ...

  5. C# 关闭登录窗体,显示主窗体

    首先在programm.cs里设置登录窗体显示 static class Program    {        /// <summary>        /// The main ent ...

  6. q检验|新复极差法|LSD|二因素方差分析

    生物统计与实验设计 放大程度q检验:精度较高>新复极差法:各种错误比较平均>LSD 其中,LSD不随M的变化而变化,但是SSR和q-test会随M变化而变化. 第一步代表了方差分析的核心思 ...

  7. Euler characteristic

    Euler characteristic Euler定理 顶点(v),棱数(edge)(e),面(J) 尽管我们有四个不同的四面体,但是如果我们将顶点数\((v)\)减去棱数\((e)\)再加上四面体 ...

  8. 高可用(keepalived+lvs)

    博主本人平和谦逊,热爱学习,读者阅读过程中发现错误的地方,请帮忙指出,感激不尽 架构图: 本次实验严格按照下图完成 1.系统环境设置 1.1SELinux设置 vim /etc/selinux/con ...

  9. python后端面试第二部分:网络编程和并发编程--长期维护

    1. 简述 OSI 七层协议. 2. 什么是C/S和B/S架构? 3. 简述 三次握手.四次挥手的流程. 4. 什么是arp协议? 5. TCP和UDP的区别? 6. 什么是局域网和广域网? 7. 为 ...

  10. prototype与__proto__

    __proto__是每个对象都有的一个属性,而prototype是函数才会有的属性!!! 使用Object.getPrototypeOf()代替__proto__!!! 一.prototype 几乎所 ...