<template>
<view class="container">
<view class="username"> <input type="text" v-model="username" placeholder="用户名" /> </view>
<view class="password"> <input type="password" v-model="password" placeholder="密码" /> </view>
<view class="denglu"> <button @click="login">登录</button></view>
</view>
</template>
<script>
export default {
data() {
return {
username: '',
password: ''
};
},
methods: {
login() {
// 登录验证
if (this.username === 'admin' && this.password === '123456') {
uni.redirectTo({
url: '/pages/index/index'
});
} else {
uni.showToast({
title: '登录失败,请检查用户名和密码',
icon: 'none'
});
}
}
}
};
</script>
<style scoped>
.container{
position: absolute;
justify-content: center;
flex-direction:column;
left: 0;
right: 0;
top: 260px;
}
</style>
10-24
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-04
3614
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-09
9850
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-18
1462
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-26
4653
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-10
3903
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)