【问题标题】:How to display following response using vue js?如何使用 vue js 显示以下响应?
【发布时间】:2018-05-01 07:49:50
【问题描述】:

这是我的回复.. 如何显示错误信息?密码不匹配

 {"errors": {"password": ["Passwords donot match"]}, "status": false, "msg": "Validation erro", "error-type": 0}

目前我的代码是

<script>
regBox = new Vue({
el: "#regBox",
  data: {
   ..........
    response: {
        message: '',
        status: '',
        state: '',
        errors: '',
    }
  },
methods: {
     handelSubmit: function(e) {
           var vm = this;
           data = {};
         ..............
            $.ajax({
              url: '',
              data: data,
              type: "POST",
              dataType: 'json',
              success: function(e) {
              if (e.status)
              {
               alert(" Success")

            }
              else {
                vm.response = e;
               alert(" Failed") 
              }
          }
            });
            return false;
}
},
});
</script>

我的显示相同的html代码是

 <p class="error">{{response.errors.password}}</p>

目前我收到错误消息 [“密码不匹配”]

如何只获取消息

密码不匹配..那么,我怎么能得到它..谁能帮忙

【问题讨论】:

    标签: javascript jquery vue.js vue-component


    【解决方案1】:

    这应该可行:

    <p class="error">{{response.errors.password[0]}}</p>
    

    【讨论】:

      【解决方案2】:

      获取第一个元素

      <p class="error">{{response.errors.password[0]}}</p>
      

      【讨论】:

        猜你喜欢
        • 2018-04-01
        • 2018-04-15
        • 2019-07-31
        • 2023-02-15
        • 1970-01-01
        • 2020-03-28
        • 2016-10-15
        • 2018-04-02
        • 2021-09-28
        相关资源
        最近更新 更多