微信小程序2

84 阅读1分钟

wxml:

    账号:<input class="is" auto-focus placeholder="将会获取焦点" bindinput="bindKeyInput1" />
    密码:<input class="is" password type="text" placeholder="这是一个密码输入框" bindinput="bindKeyInput2" />
    <button bindtap="cun">提交存储账号</button>
</view>



js:

        inputVal1:'',
        inputVal2:''
    },
    bindKeyInput1:function(e){
        let {detail:{value}} = e;
        this.setData({
            inputVal1:value
        })
    },
    bindKeyInput2:function(e){
        let {detail:{value}} = e;
        this.setData({
            inputVal2:value
        })
    },
    cun:function(){
        wx.setStorageSync('username',this.data.inputVal1);
        wx.setStorageSync('password',this.data.inputVal2);
    },

css:

    border: 1px solid black;
    margin: 10px 5px;
}