Click here to Skip to main content
15,887,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi a have code html.
HTML
<pre> <form class="m-t panel" role="form" id="login">
                            <div class="panel-heading">
                                <div class="panel-title"> </div>
                            </div>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <span class="glyphicon glyphicon-envelope"></span>
                                </div>
                                <input type="text" upperCase="true" class="form-control" 
                                      placeholder="Thông tin người sử dụng" v-bind:value="userName">
                                
                            </div>
                            <div class="input-group" style="padding-top:10px !important;">
                                <div class="input-group-addon">
                                    <span class="glyphicon glyphicon glyphicon-log-out"></span>
                                </div>
                                <input type="password" class="form-control" placeholder="Thông tin mật khẩu" v-bind:value="pw">
                            </div>
                            <button type="button" class="btn btn-primary block full-width m-b" style="margin-top:10px;" v-on:click="dangnhap()">
                                
                                Login
                            </button>
                            <a href="#">
                                <small>Quên mật khẩu?</small>
                            </a>
                            <p class="text-muted text-center">
                            </p>
                        </form>



i used this code get value when click button

JavaScript
var rootUrl="@Core.Constants.Config.GetBaseUrl()";

       var login = new Vue(
           {
               el: "#login",
               data: {
                   userName: "",
                   pw: "",
               }
               ,
               methods: {
                   dangnhap: function (evt) {
                       debugger;



                   }
               }
           }
       );


but value is nulll.

thanks to support

What I have tried:

i used js but it not run

<pre lang="Javascript">


 var rootUrl="@Core.Constants.Config.GetBaseUrl()";

        var login = new Vue(
            {
                el: "#login",
                data: {
                    userName: "",
                    pw: "", 
                }
                ,
                methods: {
                    dangnhap: function (evt) {
                        debugger;

                         

                    }
                }
            }
        );
Posted
Updated 13-Oct-18 3:29am

1 solution

I think you forgot the the return {} like

data() {

return {

userName: "",
pw: ""

}

},

methods: {

dangnhap() {

alert(`my username is ${this.userName} and my password is ${this.pw}`);

}


}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900