Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
6001d8c1
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6001d8c1
编写于
6月 17, 2023
作者:
Y
yurj26
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(input): add auto focus
上级
fb05f608
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
32 deletion
+35
-32
pages/component/input/input.uvue
pages/component/input/input.uvue
+35
-32
未找到文件。
pages/component/input/input.uvue
浏览文件 @
6001d8c1
...
@@ -2,12 +2,12 @@
...
@@ -2,12 +2,12 @@
<view class="nvue-page-root">
<view class="nvue-page-root">
<page-head :title="title"></page-head>
<page-head :title="title"></page-head>
<view class="uni-common-mt">
<view class="uni-common-mt">
<
!-- <
view class="uni-form-item uni-column">
<view class="uni-form-item uni-column">
<view class="title"><text class="uni-form-item__title">可自动聚焦的 input</text></view>
<view class="title"><text class="uni-form-item__title">可自动聚焦的 input</text></view>
<view class="uni-input-wrapper">
<view class="uni-input-wrapper">
<input class="uni-input" :focus="true" placeholder="自动获得焦点" ref="input"/>
<input class="uni-input" :focus="true" placeholder="自动获得焦点" ref="input"/>
</view>
</view>
</view>
-->
</view>
<!-- #ifdef APP-PLUS -->
<!-- #ifdef APP-PLUS -->
<!-- <view v-if="platform==='ios'&&!isNvue" class="uni-form-item uni-column">
<!-- <view v-if="platform==='ios'&&!isNvue" class="uni-form-item uni-column">
<view class="title"><text class="uni-form-item__title">隐藏 iOS 软键盘上的导航条</text></view>
<view class="title"><text class="uni-form-item__title">隐藏 iOS 软键盘上的导航条</text></view>
...
@@ -84,20 +84,20 @@
...
@@ -84,20 +84,20 @@
<view class="uni-input-wrapper">
<view class="uni-input-wrapper">
<input class="uni-input" placeholder-style="color:#F76260" placeholder="占位符字体是红色的" />
<input class="uni-input" placeholder-style="color:#F76260" placeholder="占位符字体是红色的" />
</view>
</view>
</view>
</view>
<view class="uni-form-item uni-column">
<view class="uni-form-item uni-column">
<view class="title"><text class="uni-form-item__title">带清除按钮的输入框</text></view>
<view class="title"><text class="uni-form-item__title">带清除按钮的输入框</text></view>
<view class="uni-input-wrapper">
<view class="uni-input-wrapper">
<input class="uni-input" placeholder="带清除按钮的输入框" :value="inputClearValue" @input="clearInput" />
<input class="uni-input" placeholder="带清除按钮的输入框" :value="inputClearValue" @input="clearInput" />
<image class="uni-icon" src="/static/icons/clear.png" v-if="showClearIcon" @click="clearIcon"></image>
<image class="uni-icon" src="/static/icons/clear.png" v-if="showClearIcon" @click="clearIcon"></image>
</view>
</view>
</view>
</view>
<view class="uni-form-item uni-column">
<view class="uni-form-item uni-column">
<view class="title"><text class="uni-form-item__title">可查看密码的输入框</text></view>
<view class="title"><text class="uni-form-item__title">可查看密码的输入框</text></view>
<view class="uni-input-wrapper">
<view class="uni-input-wrapper">
<input class="uni-input" placeholder="请输入密码" :password="showPassword" />
<input class="uni-input" placeholder="请输入密码" :password="showPassword" />
<image class="uni-icon" :src="!showPassword ? '/static/icons/eye-active.png': '/static/icons/eye.png'" @click="changePassword"></image>
<image class="uni-icon" :src="!showPassword ? '/static/icons/eye-active.png': '/static/icons/eye.png'" @click="changePassword"></image>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -114,7 +114,10 @@
...
@@ -114,7 +114,10 @@
changeValue: '',
changeValue: '',
showPassword: true
showPassword: true
}
}
},
},
onReady() {
(this.$refs['input'] as INode).focus();
},
methods: {
methods: {
onKeyInput: function (event : InputEvent) {
onKeyInput: function (event : InputEvent) {
this.inputValue = event.detail.value
this.inputValue = event.detail.value
...
@@ -124,21 +127,21 @@
...
@@ -124,21 +127,21 @@
if (value == '11') {
if (value == '11') {
this.changeValue = '2';
this.changeValue = '2';
}
}
},
},
clearInput: function(event: InputEvent) {
clearInput: function(event: InputEvent) {
this.inputClearValue = event.detail.value;
this.inputClearValue = event.detail.value;
if (event.detail.value.length > 0) {
if (event.detail.value.length > 0) {
this.showClearIcon = true;
this.showClearIcon = true;
} else {
} else {
this.showClearIcon = false;
this.showClearIcon = false;
}
}
},
},
clearIcon: function() {
clearIcon: function() {
this.inputClearValue = '';
this.inputClearValue = '';
this.showClearIcon = false;
this.showClearIcon = false;
},
},
changePassword: function() {
changePassword: function() {
this.showPassword = !this.showPassword;
this.showPassword = !this.showPassword;
},
},
// hideKeyboard: function(event: InputEvent) {
// hideKeyboard: function(event: InputEvent) {
// if (event.detail.value === '123') {
// if (event.detail.value === '123') {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录