• vue2 修改密码 (4)


    一,登陆页面  页面代码 

    1. <template>
    2. <div class="img">
    3. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px">
    4. <div class="nav">
    5. <el-form-item label="旧密码" prop="oldpasswold">
    6. <el-input v-model="ruleForm.oldpasswold"></el-input>
    7. </el-form-item>
    8. <el-form-item label="新密码" prop="passwold">
    9. <el-input v-model="ruleForm.passwold"></el-input>
    10. </el-form-item>
    11. <el-form-item label="确认新密码" prop="newpasswold">
    12. <el-input v-model="ruleForm.newpasswold"></el-input>
    13. </el-form-item>
    14. <button @click="denglu" class="but"> 修改密码</button>
    15. </div>
    16. </el-form>
    17. </div>
    18. </template>
    19. <script>
    20. import axios from 'axios';
    21. export default {
    22. data() {
    23. return {
    24. ruleForm: {
    25. oldpasswold:'',
    26. passwold:'',
    27. newpasswold:"",
    28. },
    29. rules: {
    30. oldpasswold: [
    31. { required: true, message: '请输入活动名称', trigger: 'blur' },
    32. { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
    33. ],
    34. passwold: [
    35. { required: true, message: '请输入活动名称', trigger: 'blur' },
    36. { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
    37. ],
    38. newpasswold: [
    39. { required: true, message: '请输入活动名称', trigger: 'blur' },
    40. { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
    41. ],
    42. }
    43. };
    44. },
    45. methods: {
    46. denglu() {
    47. // axios数据请求
    48. axios.post("/api?oldpasswold=zhou&newpasswold=zhou11&passwold=zhou11") //路径换成自己的
    49. .then(response => {
    50. //判断是不是 json
    51. // if (typeof (response.data) == 'string') {
    52. // response.data = JSON.parse(response.data.trim());
    53. // }
    54. console.log(response.data )
    55. if (this.ruleForm.oldpasswold === response.data.args.oldpasswold && this.ruleForm.passwold === response.data.args.passwold && this.ruleForm.newpasswold === response.data.args.newpasswold ) {
    56. console.log('修改成功 ')
    57. // alert('成功')
    58. this.$router.push({ path: "/Demo" }); //判断成功 跳转到新的页面
    59. }else if( !this.ruleForm.passwold === this.ruleForm.newpasswold ){
    60. console.log('密码不相同')
    61. } else {
    62. // alert('登录失败')
    63. console.log('修改失败')
    64. }
    65. })
    66. .catch(error => {
    67. console.log(error, '失败');
    68. });
    69. }
    70. }
    71. }
    72. </script>
    73. <style lang="less">
    74. .img {
    75. height: 45rem;
    76. display: flex;
    77. justify-content: center;
    78. align-items: center;
    79. background: url('../assets/photo-1684341326866-ad9fdde2314c.webp')center center no-repeat;
    80. background-size: 100% 100%
    81. }
    82. .nav {
    83. border-radius: 10px;
    84. padding: 52px 54px 52px 0;
    85. width: 100%;
    86. background: linear-gradient(rgb(158, 116, 116), rgb(138, 138, 205));
    87. }
    88. .but {
    89. margin-left: 44px;
    90. margin-top: -22px;
    91. width: 83px;
    92. height: 40px;
    93. background-color: cornflowerblue;
    94. }
    95. .jizhu {
    96. margin-top: -17px;
    97. margin-left: 116px;
    98. }</style>

    axios 安装

    npm install axios

    main.js   根据自己需要截取

    1. import Vue from 'vue'
    2. import App from './App.vue'
    3. import router from './router'
    4. import store from './store'
    5. import echarts from 'echarts'
    6. import ElementUI from 'element-ui'
    7. import 'element-ui/lib/theme-chalk/index.css'
    8. Vue.config.productionTip = false
    9. Vue.use(ElementUI)
    10. import dataV from '@jiaminghi/data-view'
    11. Vue.use(dataV)
    12. var axios = require('axios')
    13. axios.default.baseURL = '/api'
    14. Vue.prototype.$http = axios //正确的使用
    15. new Vue({
    16. router,
    17. store,
    18. render: h => h(App)
    19. }).$mount('#app')

    展示


    二,数字加加  效果展示 

    代码 

    1. <template>
    2. <div>
    3. <h1>数字:{{ this.counter}}</h1>
    4. <button @click="plusOne">点击加1</button>
    5. </div>
    6. </template>
    7. <script>
    8. export default {
    9. name: "App",
    10. data() {
    11. return {
    12. counter: 0,
    13. };
    14. },
    15. methods: {
    16. plusOne() {
    17. this.counter++;
    18. },
    19. },
    20. };
    21. </script>

  • 相关阅读:
    STM32初学-外部RTC时钟芯片DS3231
    外中断的应用
    oracle数据库定义语言—DDL
    【关于Java:认识异常】
    编写shell脚本,利用mysqldump实现MySQL数据库分库分表备份
    Javaweb基础-前端工程化学习笔记
    机器学习和深度学习相关指标和方法
    Hadoop学习记录2--hadoop的概述、部署、使用
    一键自动化博客发布工具,用过的人都说好(cnblogs篇)
    Drozer安装
  • 原文地址:https://blog.csdn.net/weixin_68266812/article/details/133747218