axios不发布表单数据

时间:2017-09-20 07:11:40

标签: javascript vue.js axios

我在vue.js注册组件中有这个功能

register: function () {
  console.log('username,passwor,email', this.username, this.password, this.email);
      axios.post( this.BASE_URL + "/api/register", {
      email: this.email,
      username: this.username,
      password: this.password,
    }).then(function(data){
      console.log(data);
    });
}

以下是注册表格:

<form id="signupform" class="form-horizontal" role="form">

<div id="signupalert" style="display:none" class="alert alert-danger">
    <p>Error:</p>
    <span></span>
</div>



<div class="form-group">
    <label for="email" class="col-md-3 control-label">email</label>
    <div class="col-md-9">
        <input type="text" class="form-control" name="email"  v-model="email"  placeholder="email">
    </div>
</div>

<div class="form-group">
    <label for="username" class="col-md-3 control-label">username</label>
    <div class="col-md-9">
        <input type="text" class="form-control" name="username" v-model="username"  placeholder="username">
    </div>
</div>

<div class="form-group">
    <label for="password" class="col-md-3 control-label">password</label>
    <div class="col-md-9">
        <input type="password" class="form-control" name="password" v-model="password"  placeholder="password">
    </div>
</div>

<div class="form-group">
    <!-- Button -->                                        
    <div class="col-md-offset-3 col-md-9">
        <button @click="register()" id="btn-signup" type="button" class="btn btn-info"><i class="icon-hand-right" ></i> Register</button>                                        
    </div>
</div>

</form>

奇怪的是,当调用该函数时,我可以在控制台中看到控制台中记录了'usernamepassworemail值。但在后端,已发布表单中的已接收字段为空。

这里可能有什么问题?

0 个答案:

没有答案