SpringBoot+SpringSecurity+Angular6简单的登录控制权限控制Demo(二)

SpringBoot+SpringSecurity+Angular6简单的登录控制权限控制Demo(二)

接上一篇 https://blog.csdn.net/cepto/article/details/85331386
有了后端服务器,接下来就是编写我们的angular6前端项目了

1.angularJS 与 angular 的区别

angularJS是初代 angular是2代以后的称呼,他们的区别可以用两个不同的框架来形容了,所以新手同学一定要注意区别,很多东西不能通用。
PS.编写angular项目老是搜到angularJS的资源真是很难受。

2.项目初始化

我的开发环境是先安装nvm再用nvm安装node9再用npm安装angular6
有了环境后开始创建项目。
这里我的样式单选用了scss可以简化css编写且样式结构更清晰。

[zz@zz-pc security-front]$ ng new security-front --style=scss

然后安装jq和bootstrap

[zz@zz-pc security-front]$ npm i jquery bootstrap

安装好后需要再angular.json中配置一下才能生效

			"styles": [
              "src/styles.scss",
              "./node_modules/bootstrap/dist/css/bootstrap.css"
            ],
            "scripts": [
              "./node_modules/jquery/dist/jquery.js",
              "./node_modules/bootstrap/dist/js/bootstrap.js"
            ]

接下来把全局的样式重置一下

styles.scss

/* You can add global styles to this file, and also import other style files */
/* http://meyerweb.com/eric/tools/css/reset/
   v2.0 | 20110126
   License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
   
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
   
  display: block;
}
body {
   
  line-height: 1;
}
ol, ul {
   
  list-style: none;
}
blockquote, q {
   
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
   
  content: '';
  content: none;
}
table {
   
  border-collapse: collapse;
  border-spacing: 0;
}

这样我们的项目初始化工作就做好了。

3.页面设计

在这里插入图片描述
对应路由关系
在这里插入图片描述

4.一级路由,登录和index组件

首先添加index和login两个组件

[zz@zz-pc security-front]$ ng g c page/login
[zz@zz-pc security-front]$ ng g c page/index

然后添加路由模块

[zz@zz-pc security-front]$ ng g m app-routing --flat --module=app

flat表示不为路由新建单独的文件夹,–module=app表示自动注册到根模块中

app-routing.module.ts

import {
   NgModule} from '@angular/core';
import {
   CommonModule} from '@angular/common';
import {
   LoginComponent} from './page/login/login.component';
import {
   IndexComponent} from './page/index/index.component';
import {
   RouterModule, Routes} from "@angular/router";

const appRoutes: Routes =
    [
        {
   
            path: '',
            component: IndexComponent,            
        },
        {
   
            path: 'login',
            component: LoginComponent
        },
    ];

@NgModule({
   
    imports: [
        CommonModule,
        RouterModule.forRoot(appRoutes)
    ],
    exports: [RouterModule],<
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
SpringBoot和Vue.js是两个流行的技术,分别用于后端和前端开发。下面是它们的优缺点: SpringBoot的优点: 1. 快速开发:SpringBoot可以快速搭建一个基础的Web服务,开发者只需要关注业务逻辑的实现,而不必关注底层的技术细节。 2. 高度集成:SpringBoot内置多种常用的框架和工具,如Spring MVC、MyBatis、JPA、Thymeleaf等,使得开发者可以更便捷地集成这些框架和工具。 3. 易于部署:SpringBoot可以将应用程序打包成一个可执行的JAR文件,并且可以与容器无关地运行,这使得应用程序的部署和维护变得更加容易。 SpringBoot的缺点: 1. 学习曲线较陡峭:SpringBoot的技术栈比较复杂,需要开发者具备一定的Java和Spring框架的基础知识。 2. 依赖管理较为复杂:SpringBoot使用Maven或Gradle作为项目构建工具,需要管理大量的依赖库,对开发者的依赖管理能力要求较高。 Vue.js的优点: 1. 数据驱动:Vue.js采用双向数据绑定的方式,可以自动更新视图,让开发者更加专注于业务逻辑的实现。 2. 组件化开发:Vue.js将页面分解为多个组件,每个组件都有自己的数据和行为,使得代码结构更加清晰和模块化。 3. 高效渲染:Vue.js采用虚拟DOM技术进行高效的页面渲染,使得应用程序的性能得到了提升。 Vue.js的缺点: 1. 生态系统相对较小:相比于React和Angular,Vue.js的生态系统相对较小,可能缺乏某些功能和组件。 2. 对于大型应用的处理能力有限:Vue.js适合构建中小型的单页应用,但是对于大型应用的处理能力有限,可能需要较多的优化和调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值