springboot vue 登入頁面(三)

2022-08-25 00:24:12 字數 3573 閱讀 1784

真是開始前端工作:

準備工作:

1.建立對應的資料夾,在config/index.js 中設定基本路徑及跨域配置

2.router/index.js   負責頁面進行路由**

import vue from 'vue'import router from 'vue-router'import login from '../views/login'import main from '../views/main'vue.use(router);

export

default

newrouter(,

]})

3.建立views/login.vue 頁面,使用axios.post 方式進行傳送表單資料

<

template

>

<

el-form

:model

="dataform"

:rules

="rules"

>

<

el-form-item

label

="賬號"

prop

="username"

>

<

el-input

type

="text"

v-model

="dataform.username"

placeholder

="請輸入賬號"

>

el-input

>

el-form-item

>

<

el-form-item

label

="密碼"

prop

="password"

>

<

el-input

type

="password"

v-model

="dataform.password"

placeholder

="請輸入密碼"

>

el-input

>

el-form-item

>

<

el-button

@click

="submit1"

>登入

el-button

>

el-form

>

template

>

<

script

>

export

default

, rules: ],

password: }}

},methods: }).

catch

((res)

=>

); }

}}script

>

<

style

scoped

>

style

>

4.建立views/main.vue  通過使用axios.get 方式獲取後台資料並通過  :data=「tabledata」  對資料進行繫結載入

<

template

>

<

el-table

:data

="tabledata"

style

="width: 100%"

>

<

el-table-column

prop

="name"

label

="名稱"

width

="180"

>

el-table-column

>

<

el-table-column

prop

="password"

label

="密碼"

width

="180"

>

el-table-column

>

<

el-table-column

prop

="createtime"

label

="日期"

width

="180"

>

el-table-column

>

el-table

>

template

>

<

script

>

export

default

},created() ,

methods: )

.catch

((error)

=>

); }

}}script

>

<

style

scoped

>

style

>

<

template

>

<

div

id>

<

router-view

/>

div>

template

>

<

script

>

export

default

script

>

<

style

>

style

>

6.在main.js 檔案中引用router,element ui ,axios

// the vue build version to load with the `import` command

// (runtime-only or standalone) has been set in webpack.base.conf with an alias.

import vue from 'vue'

import vuerouter from 'vue-router'

import router from './router'

import axios from 'axios'

import vueaxios from 'vue-axios'

import elementui from 'element-ui'

import 'element-ui/lib/theme-chalk/index.css'

vue.use(vuerouter);

vue.use(vueaxios,axios);

vue.use(elementui);

vue.config.productiontip = false

/* eslint-disable no-new */

new vue()

springboot vue (跨域問題)

在後端使用spring boot。spring boot跨域非常簡單,只需書寫以下 即可。configuration public class customcorsconfiguration bean public corsfilter corsfilter spring boot應用用nginx反...

springboot vue (跨域問題)

if request method get 其中 add header access control expose headers 務必加上你請求時所帶的header。例如本例中的 token 其實是前端傳給後端過來的。如果記不得也沒有關係,瀏覽器的偵錯程式會有詳細說明。chrome firefox...

springboot vue 許可權管理系統

注意因為給了超級管理員的許可權給大家玩,所有資訊都可以操作,建議還是新建一些資訊自己隨便操作,隨意修改的話有可能改不回來 系統原始碼,可能存在一些小問題,如果需要幫助,可以加qq群 850482997 新建立的使用者密碼是 czh123,密碼重置之後也是這個 demo 前端後端 簡介該許可權管理專案...