美文网首页
SPA,单页应用和(一级路由)脚手架程序的构建

SPA,单页应用和(一级路由)脚手架程序的构建

作者: 啊肉怪 | 来源:发表于2019-04-17 20:11 被阅读0次

1场景

1.1后台管理系统

1.1.1、技术栈

  • SpringBoot、vue-cli SPA、npm、ElementUI

1.1.2、IDE

  • WB、VS code、HB

1.2 H5前端开发

1.2.1、技术栈

  • vue-cli、npm、建议自己布局手写样式

1.2.2、IDE

  • WB、VS code、HB

1.3 跨端APP开发

1.3.1、技术栈

  • uni-app、Flutter、RN、cordova(调用底层API)

1.3.2、IDE

  • HB、打包可安装的APP

后端配置跨域

  • 1、在pom.xml文件中添加swagger依赖
<dependency>
           <groupId>com.spring4all</groupId>
           <artifactId>swagger-spring-boot-starter</artifactId>
           <version>1.8.0.RELEASE</version>
       </dependency>

  • 2.项目结构,config包下放入一个配置类

    image
WebMvcConfigurer类
package com.springboot.mybatis.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
    //跨域配置
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            //重写父类提供的跨域请求处理的接口
            public void addCorsMappings(CorsRegistry registry) {
                //添加映射路径
                registry.addMapping("/**")
                        //放行哪些原始域
                        .allowedOrigins("*")
                        //是否发送Cookie信息
                        .allowCredentials(true)
                        //放行哪些原始域(请求方式)
                        .allowedMethods("GET", "POST", "PUT", "DELETE")
                        //放行哪些原始域(头部信息)
                        .allowedHeaders("*")
                        //暴露哪些头部信息(因为跨域访问默认不能获取全部头部信息)
                        .exposedHeaders("Header1", "Header2");
            }
        };
    }
}

注意:配置文件加注解:@Configuration

  • 3.、主类开启注解
@EnableSwagger2Doc

2、一个Vue单页应用(一级路由)脚手架程序的构建

  • 进入某个目录如:D:\VueStudy

  • 通过命令创建项目:vue init webpack vue-router-demo1(后几项都选择N)

  • cd进入vue-router-demo1目录

    image
  • 安装依赖:npm install

  • 运行npm run dev

  • 更改config目录下的Index.js文件,将端口号改成80

  • 进行一级路由配置
    AppVue
    router文件夹的index.js文件
    components文件夹建立相应的软件
    1.Index.vue
    2.Message.vue
    改造

  • index.js文件

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
    mode:"history",
   routes: [
    {
        //我的班课
      path: '/',
      name: 'Index',
      component: resolve => require(['../components/Index.vue'],resolve)
    },
    {
        //消息
        path:'/task',
        name:'Task',
        component: resolve => require(['../components/Task.vue'],resolve)
    },
    {
        //库管理
        path:'/lib',
        name:'Lib',
        component: resolve => require(['../components/Lib.vue'],resolve)
    },
    {
        //个人中心
        path:'/ucenter',
        name:'UCenter',
        component: resolve => require(['../components/UCenter.vue'],resolve)
    },
    {
        //新建班课
        path:'/new_course',
        name:'NewCourse',
        component: resolve => require(['../components/NewCourse.vue'],resolve)
    },
    {
        //班课详情
        path: '/course/:id',
        name: 'CourseDetail',
        component: resolve => require(['../components/CourseDetail.vue'], resolve)
    }
  ]
})

  • components文件夹建立相应的组件

相关文章

  • 实现蓝墨云

    建立一级路由vue-router-demo1一个vue的单页应用(一级路由)的脚手架程序构建1.进入某个目录如D:...

  • 笔记1

    1、SPA:单页应用 2、 一级路由demo 脚手架:vue-router-demo1 写样式 把相应的API...

  • 9、SPA单页应用(一级路由)

    本例主要采用路由配置,实现上面导航不动,下面页面可跳转的功能 一个vue的单页应用(一级路由)的脚手架程序构建1....

  • Eighth SPA单页应用(一级路由)

    本例主要采用路由配置,实现上面导航不动,下面页面可跳转的功能 一个vue的单页应用(一级路由)的脚手架程序构建1....

  • SPA单页应用(一级路由)

    一个vue的单页应用(一级路由)的脚手架程序构建 命令行先进入某个目录如D:\VueStudy 创建项目: vue...

  • SPA单页应用

    一个vue的单页应用(一级路由)的脚手架程序构建1.进入某个目录如D:\VueStudy2.通过命令创建项目:vu...

  • SPA单页应用(一级路由)

    一个vue的单页应用(一级路由)的脚手架程序构建 1.命令行先进入某个目录如D:\VueStudy2.创建项目: ...

  • Vue初步导航框架

    一个vue的单页应用(一级路由)的脚手架程序构建1.进入某个目录如D:\VueStudy2.通过命令创建项目:vu...

  • 1 SPA单页应用

    一个vue的单页应用(一级路由)的脚手架程序构建1.进入某个目录如D:\VueStudy2.通过命令创建项目:vu...

  • 15 SPA单页应用

    一个vue的单页应用(一级路由)的脚手架程序构建1.进入某个目录如D:\VueStudy2.通过命令创建项目:vu...

网友评论

      本文标题:SPA,单页应用和(一级路由)脚手架程序的构建

      本文链接:https://www.haomeiwen.com/subject/gfsowqtx.html