发表于: 2020-06-16 23:06:14

1 2221


今天完成的事情:今天写了路由的跳转
明天计划的事情:继续后续的任务
遇到的问题:实际写起来还是老出问题还是要仔细看清楚
收获:今天写了基本的结构

import { NgModule } from '@angular/core';
import { RoutesRouterModule } from '@angular/router';


const routesRoutes = [
  {
    path: 'login',
    loadChildren:()=>import('./modules/login/login.module').then(mod=>mod.LoginModule)
},
  {
    path: 'page',
    loadChildren:()=>import('./modules/page/page.module').then(mod=>mod.PageModule)
}


];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

登录HTML

<body>
    <div class="main">
        <div class="top">后台登录</div>
        <input type="text" id="user" placeholder="用户名" [(ngModel)]="account.name">
        <input type="password" id="pwd" placeholder="密码" [(ngModel)]="account.pwd">
        <div id="addText"></div>
        <button id="footer" (click)="login()">登录</button>
    </div>
</body>

css

body {
    background-size100% 100%;
    padding-top140px;
    backgroundurl(../../../assets/image/3.png)no-repeat;
    background-size100% 100%;
    height100%;
    background-attachment:fixed;
  }
  
  body .main {
    displayflex;
    flex-directioncolumn;
    align-contentcenter;
    width400px;
    height320px;
    margin0px auto;
    padding6px 50px 30px 50px;
    border-radius10px;
    background-colorrgba(2502502500.5);
  }
  
  body .main .top {
    text-aligncenter;
    font-weight700;
    font-size24px;
    margin-bottom60px;
  }
  
  body .main input {
    height35px;
    border-radius10px;
    margin-bottom18px;
    padding-left40px;
    background-color#fff !important;
    bordernone;
    outlinenone;
  }
  
  body .main input:nth-child(2) {
    backgroundurl(../../../assets/image/user.png5px 5px/25px 25px no-repeat;
  }
  
  body .main input:nth-child(3) {
    backgroundurl(../../../assets/image/password.png5px 5px/25px 25px no-repeat;
  }
  
  body .main #addText {
    height20px;
    line-height20px;
    font-weight700;
    color#f1c40f;
    text-aligncenter;
  }
  
  body .main #footer {
    width300px;
    height35px;
    margin-top12px;
    border-radius10px;
    font-size18px;
    text-aligncenter;
    line-height35px;
    border-stylenone;
    outline-stylenone;
    cursorpointer;
  }
  
  body .main #footer:hover {
    backgroundblack;
    color#fff;
  }
  

路由设置

import { NgModule } from '@angular/core';
import { RoutesRouterModule } from '@angular/router';
import { LoginComponent } from './login.component';

const routesRoutes = [
  { path:'',component:LoginComponent}
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule
    ]
})
export class LoginRoutingModule { }

page页面路由设置

import { NgModule } from '@angular/core';
import { RoutesRouterModule } from '@angular/router';
import { PageComponent } from './page.component';

const routesRoutes = [
  {path:'',component: PageComponent}
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class PageRoutingModule { }

效果

配置跨域

主要原理参考

文件配置

{
    "/a/": {
        "target""http://dev.admin.carrots.ptteng.com/",
        "secure""false",
        "changeOrigin"true
        
    }
}

package.json设置

"scripts": {
    "ng""ng",
    "start""ng serve --proxy-config proxy.config.json --open",
    "build""ng build",
    "test""ng test",
    "lint""ng lint",
    "e2e""ng e2e"

使用npm srart来启动即可

剩下的明天继续


返回列表 返回列表
评论

    分享到