Springboot+vue の組み合わせ、フロントエンドを学習するバックエンド (2)

結果表示
ここに画像の説明を挿入

上記に引き続き
、バックエンドをデータベースに接続します
。バックエンドとして、おそらく投稿します。
ここに画像の説明を挿入
ここに画像の説明を挿入

フロントエンド美化要素

ダウンロード要素

まず、関連するパッケージをプロジェクトにインストールします
ここに画像の説明を挿入

要素の導入

ここに画像の説明を挿入

テスト要素

ここに画像の説明を挿入
変更して
ここに画像の説明を挿入
結果
ここに画像の説明を挿入
を削除 v
ここに画像の説明を挿入
ここに画像の説明を挿入

美化する

element.コンポーネントを見つけるための公式 Web サイト: https://element.eleme.cn/#/zh-CN/component/form

ここに画像の説明を挿入

効果

ここに画像の説明を挿入

<template>
  <el-form class="login-container" label-position="left"
           label-width="0px">
    <h3 class="login_title">系统登录</h3>
    <el-form-item>
      <el-input type="text" v-model="loginForm.username"
                auto-complete="off" placeholder="账号"></el-input>
    </el-form-item>
    <el-form-item>
      <el-input type="password" v-model="loginForm.password"
                auto-complete="off" placeholder="密码"></el-input>
    </el-form-item>
    <el-form-item style="width: 100%">
      <el-button type="primary" style="width: 100%;background: #505458;border: none" v-on:click="login">登录</el-button>
    </el-form-item>
  </el-form>
</template>

<style>
.login-container {
  border-radius: 15px;
  background-clip: padding-box;
  margin: 90px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}

.login_title {
  margin: 0px auto 40px auto;
  text-align: center;
  color: #505458;
}
</style>

背景画像

写真を見つけてアセットに詰め込む
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入

コード全体

<template>
  <body id="poster">
  <el-form class="login-container" label-position="left"
           label-width="0px">
    <h3 class="login_title">系统登录</h3>
    <el-form-item>
      <el-input type="text" v-model="loginForm.username"
                auto-complete="off" placeholder="账号"></el-input>
    </el-form-item>
    <el-form-item>
      <el-input type="password" v-model="loginForm.password"
                auto-complete="off" placeholder="密码"></el-input>
    </el-form-item>
    <el-form-item style="width: 100%">
      <el-button type="primary" style="width: 100%;background: #505458;border: none" v-on:click="login">登录</el-button>
    </el-form-item>
  </el-form>
  </body>
</template>

<script>
export default {
    
    
  name: 'Login',
  data () {
    
    
    return {
    
    
      loginForm: {
    
    
        username: '',
        password: ''
      },
      responseResult: []
    }
  },
  // methods中login 发定义了登录按钮的点击方法,即向后端 /login 接口发送数据,获得成功的响应后,页面跳转到 /index。
  // 默认发送到http://localhost:8443/api/login
  methods: {
    
    
    login () {
    
    
      this.$axios
        .post('/login', {
    
    
          username: this.loginForm.username,
          password: this.loginForm.password
        })
        .then(successResponse => {
    
    
          if (successResponse.data.code === 200) {
    
    
            this.$router.replace({
    
    path: '/index'})
          }
        })
        .catch(failResponse => {
    
    
        })
    }
  }

}
</script>

<style>
#poster {
    
    
  background:url("../assets/eva.jpg") no-repeat;
  background-position: center;
  height: 100%;
  width: 100%;
  background-size: cover;
  position: fixed;
}
body{
    
    
  margin: 0px;
}

.login-container {
    
    
  border-radius: 15px;
  background-clip: padding-box;
  margin: 90px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}

.login_title {
    
    
  margin: 0px auto 40px auto;
  text-align: center;
  color: #505458;
}

</style>

おすすめ

転載: blog.csdn.net/m0_54765221/article/details/129188781