用微信小程序开发者工具,编写一个可以实现实时输入用户名和密码的页面,并展示js json wxml wxss 和app.js app.json等全部代码
时间: 2024-03-05 21:48:01 浏览: 151
好的,以下是实现实时输入用户名和密码的微信小程序页面的代码:
wxml:
<view class="container">
<view class="input-area">
<input placeholder="请输入用户名" bindinput="inputUsername" />
<input placeholder="请输入密码" type="password" bindinput="inputPassword" />
</view>
<view class="result-area">
<text>您输入的用户名是:{{username}}</text>
<text>您输入的密码是:{{password}}</text>
</view>
</view>
wxss:
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.input-area {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 100rpx;
}
.input-area input {
width: 500rpx;
height: 80rpx;
font-size: 36rpx;
padding-left: 20rpx;
margin-bottom: 20rpx;
border: 2rpx solid #ccc;
border-radius: 10rpx;
}
.result-area {
margin-top: 80rpx;
font-size: 36rpx;
}
js:
Page({
data: {
username: '',
password: ''
},
inputUsername(e) {
this.setData({
username: e.detail.value
})
},
inputPassword(e) {
this.setData({
password: e.detail.value
})
}
})
app.json:
{
"pages": [
"pages/index/index"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "实时输入用户名和密码",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json"
}
app.js:
App({
onLaunch: function () {
// Do something initial when launch.
},
onShow: function () {
// Do something when show.
},
onHide: function () {
// Do something when hide.
},
onError: function (msg) {
console.log(msg)
},
globalData: 'I am global data'
})
json:
{
"usingComponents": {}
}
以上就是全部代码,您可以将以上代码复制到微信小程序开发者工具中对应的文件中,即可实现实时输入用户名和密码的页面。
相关推荐















