<!-- miniprogram\pages\index\index.wxml -->
<view class="login" style="margin-top:{{statusBarHeight}}px;padding-top:44px">
<input class="login_phone" placeholder-class="phcolor" type="text" placeholder="输入字符串" bindinput="updateValue" data-key="str" />
<view>{{str}}</view>
</view>
// miniprogram\pages\index\index.js
Page({
data: {
//顶部安全距离(状态栏高度)
statusBarHeight: wx.getSystemInfoSync().statusBarHeight,
str: ''
},
onLoad: function () {},
updateValue: function(e){
let key = e.currentTarget.dataset.key;
let value = e.currentTarget.dataset.value;
let obj = {};
obj[key] = e.detail && e.detail.value;
this.setData(obj);
}
})