File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 </ button >
66
77 < modal title ="testtitle ">
8- < form-input type ="text " name ="username " title ="用户名 " icon ="user "> </ form-input >
9- < form-input type ="password " name ="password " title ="密码 " icon ="lock "> </ form-input >
10- < div class ="form-group ">
11- < input class ="form-control " type ="text " data-tabindex ="1 ">
12- </ div >
13- < div class ="form-group ">
14- < input class ="form-control " type ="text " data-tabindex ="2 ">
15- </ div >
16- < button class ="btn blue " data-toggle ="modal " href ="#stack2 "> Launch modal</ button >
8+
9+ < form action ="# " class ="form-horizontal " role ="form ">
10+ < div class ="form-body ">
11+ < form-input name ="username " title ="用户名 " horizontal > </ form-input >
12+ < form-input type ="password " name ="password " title ="密码 " horizontal > </ form-input >
13+ </ div >
14+ </ form >
15+
1716 </ modal >
1817
1918</ div >
Original file line number Diff line number Diff line change 1- < div class ="form-group ">
1+ < div class ="form-group " v-if ="horizontal ">
2+ < label class ="col-md-{{colLeft}} control-label " v-if ="!hidetitle "> {{ title }}</ label >
3+ < div class ="col-md-{{colRight}} ">
4+ < input name ="{{ name }} " type ="{{ type }} " class ="form-control " autocomplete ="{{autocomplete}} ">
5+ </ div >
6+ </ div >
7+
8+ < div class ="form-group " v-else >
29 <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
310 < label class ="control-label visible-ie8 visible-ie9 " v-if ="!hidetitle "> {{ title }}</ label >
411 < div class ="input-icon ">
512 < i class ="fa fa-{{ icon }} " v-if ="icon "> </ i >
6- < input class =" form-control placeholder-no-fix " type ="{{ type }} " autocomplete =" off " placeholder ="{{ title }} " name ="{{ name }} " />
13+ < input name =" {{ name }} " type ="{{ type }} " class =" form-control placeholder-no-fix " autocomplete ="{{autocomplete }} " placeholder ="{{ title }} " />
714 </ div >
8- </ div >
15+ </ div >
Original file line number Diff line number Diff line change @@ -37,6 +37,59 @@ Vue.component('form-input', {
3737 type : String ,
3838 required : true
3939 } ,
40+
41+ 'autocomplete' : {
42+ type : String ,
43+ 'default' : 'on'
44+ } ,
45+
46+ 'horizontal' : {
47+ type : Boolean ,
48+ 'default' : false
49+ } ,
50+
51+ /**
52+ * 如果是水平排列的话,则需要定义左右的宽度,格式为x-x,其中x值为1到12
53+ */
54+ 'col' : {
55+ type : String ,
56+ 'default' : '3-9'
57+ }
58+
59+ } ,
60+ computed : {
61+ colLeft : function ( ) {
62+ var defaultVal = 3 ,
63+ val ;
64+
65+ if ( ! this . col ) {
66+ return defaultVal ;
67+ }
68+
69+ val = parseInt ( this . col . split ( '-' ) [ 0 ] , 10 ) ;
70+
71+ if ( isNaN ( val ) || val < 1 || val > 12 ) {
72+ return defaultVal ;
73+ } else {
74+ return val ;
75+ }
76+ } ,
77+ colRight : function ( ) {
78+ var defaultVal = 9 ,
79+ val ;
80+
81+ if ( ! this . col ) {
82+ return defaultVal ;
83+ }
84+
85+ val = parseInt ( this . col . split ( '-' ) [ 1 ] , 10 ) ;
86+
87+ if ( isNaN ( val ) || val < 1 || val > 12 ) {
88+ return defaultVal ;
89+ } else {
90+ return val ;
91+ }
92+ }
4093 } ,
4194 ready : function ( ) {
4295
You can’t perform that action at this time.
0 commit comments