码迷,mamicode.com
首页 > 微信 > 详细

第十一篇、微信小程序-input组件

时间:2016-10-23 02:17:46      阅读:369      评论:0      收藏:0      [点我收藏+]

标签:listener   http   手机   lex   pass   优先   手机号   gray   listen   

主要属性:

技术分享

效果图:

技术分享

ml:

<!--style的优先级比class高会覆盖和class相同属性-->
<!--头像-->
<view style="display:flex;justify-content: center;">
    <image  style="width:130rpx;height:130rpx;border-radius:50%;margin-top:10%;" src="../../image/logo.jpg"> </image>
</view>
<!--这个是输入框背景-->
<view class="inputView">
    <!--这个是输入框-->
    <input class="input"  type="number" placeholder="请输入账号" placeholder-style="color: gray" bindinput="listenerPhoneInput" />
</view>
<view class="inputView">
    <input class="input" password="true" placeholder="请输入密码" placeholder-style="color: gray" bindinput="listenerPasswordInput"/>
</view>
<!--登录按钮-->
<button style="margin-left: 15rpx; margin-right: 15rpx; margin-top: 50rpx; border-radius: 40rpx" type="primary" bindtap="listenerLogin">登录</button>

 

ss:

.input{
    padding-left: 10px;
    height: 44px;
}
.inputView{
    /*边界:大小1px, 为固体,为绿色*/
    border:  1px solid green;
    /*边界角的弧度*/
    border-radius: 30px;
    margin-left: 15px;
    margin-right: 15px;
    margin-top: 15px;
}

 

js:

Page({
   /**
   * 初始化数据
   */
  data:{
    phone: ‘‘,
    password: ‘‘,
  },
  /**
   * 监听手机号输入,并把输入的值保存在data变量中
   */
  listenerPhoneInput: function(e) {
      console.log(‘Phone=‘+e.detail.value)
      this.data.phone = e.detail.value;
  },
  /**
   * 监听密码输入,并把输入的值保存在data变量中
   */
  listenerPasswordInput: function(e) {
      console.log(‘Password=‘+e.detail.value)
      this.data.password = e.detail.value;
  },
  /**
   * 监听登录按钮,获取保存在data变量中的值
   */
  listenerLogin: function() {
      //打印收入账号和密码
    console.log(‘手机号为: ‘, this.data.phone);
    console.log(‘密码为: ‘, this.data.password);
  },
})

 

第十一篇、微信小程序-input组件

标签:listener   http   手机   lex   pass   优先   手机号   gray   listen   

原文地址:http://www.cnblogs.com/HJQ2016/p/5988746.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!