• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

主要属性:

效果图:

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);
  },
})

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
微信小程序资料收集(一)发布时间:2022-07-22
下一篇:
小程序弹窗禁止页面滚动发布时间:2022-07-22
热门推荐
    热门话题
    阅读排行榜

    扫描微信二维码

    查看手机版网站

    随时了解更新最新资讯

    139-2527-9053

    在线客服(服务时间 9:00~18:00)

    在线QQ客服
    地址:深圳市南山区西丽大学城创智工业园
    电邮:jeky_zhao#qq.com
    移动电话:139-2527-9053

    Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap