m0_56047852 2022-07-04 21:43 采纳率: 87.5%
浏览 42
已结题

vue的一个错误,谁能帮我看看吗

vue的,报了这个错误,搞了好久都没办法解决,有大ge帮我解决一下吗?78行就是那个报错的“then”

img

            Manger(MangerParam).then(data => {


```javascript
<template>
  <el-form
    :model="ruleForm"
    status-icon
    :rules="rules"
    ref="ruleForm"
    label-width="0px"
    class="demo-ruleForm manger-container">
    <h1 class="title">后台管理员登录</h1>
    <el-form-item  prop="mangerName">
      <el-input type="text" placeholder="请输入用户名" v-model="ruleForm.mangerName" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item  prop="password">
      <el-input type="password" placeholder="请输入密码" v-model="ruleForm.password" autocomplete="off" @keyup.enter.native="submitForm('ruleForm')"></el-input>
    </el-form-item>
    
    <el-form-item style="width:100%;">
      <el-button type="primary" style="width:100%;" @click="submitForm('ruleForm')" >登录</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  import md5 from 'md5'
  // import vueRsource from 'vue-resource'
  // Vue.use(vueRsource);
  import {mapActions} from 'vuex'
  export default {
    name: 'Manger',
    data () {
      const validateMangerName = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入用户名'))
        } else {
          if (this.ruleForm.mangerName !== '') {
            this.$refs.ruleForm.validateField('checkPass')
          }
          callback()
        }
      }
      const validatePassword = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'))
        } else {
          if (this.ruleForm.password !== '') {
            this.$refs.ruleForm.validateField('checkPass')
          }
          callback()
        }
      }    
      return {
        ruleForm: {
          mangerName: '',
          password: ''
        },
          rules: {
          mangerName: [
            {validator: validateMangerName, trigger: 'blur'}
          ],
          password: [
            {validator: validatePassword, trigger: 'blur'}
          ]
        }
      }
    },
    mounted () {
      this.draw()
    },
    methods: {
      ...mapActions(['Manger']),
      submitForm (formName) {
        const {Manger} = this
        this.$refs[formName].validate((valid) => {
          if (valid) {
            const MangerParam = {}
            MangerParam['mangerName'] = this.ruleForm.mangerName
            MangerParam['password'] = md5(this.ruleForm.password)
            Manger(MangerParam).then(data => {
              this.$router.push('/users/MangerPro', () => {
                this.$notify({
                  title: '成功',
                  message: '登陆成功',
                  type: 'success'
                });
              })
            }).catch(error => {
              this.ruleForm.password = ''
              this.draw()
              this.$message.error({
                message: error.msg
              })
            })
          } else {
            console.log('error submit!!')
            return false
          }
        })
      },
      resetForm (formName) {
        this.$refs[formName].resetFields()
      }
    }
  }
</script>

<style scoped>
  .manger-container {
    border-radius: 10px;
    margin: 0px auto;
    width: 350px;
    padding: 30px 35px 15px 35px;
    background: #fff;
    border: 1px solid #eaeaea;
    text-align: left;
    box-shadow: 0 0 20px 2px rgba(0, 0, 0, 0.1);
  }
  .title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }
  .remember {
    margin: 0px 0px 35px 0px;
  }
  .codeimg {
    height: 40px;
  }

  
</style>


```

  • 写回答

4条回答 默认 最新

  • Heerey525 前端领域新星创作者 2022-07-04 22:52
    关注

    说明你的Manger(在store中定义的不是返回一个promise)没有.then方法

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 7月13日
  • 已采纳回答 7月5日
  • 创建了问题 7月4日

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)