前端基于原生input组件的增强简单通用实用输入框
前端基于原生input组件的增强简单通用实用输入框,下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=12799
效果图如下:
实现代码如下:
# 前端基于原生input组件的增强简单通用实用输入框
#### 使用方法
```使用方法
<!-- leftTitle:左边标题 name:输入框名字 value:输入框值 placeholder:占位符 -->
<ccInputView leftTitle="姓名" name="name" value="" placeholder="请输入姓名"></ccInputView>
```
#### HTML代码部分
```html
<template>
<view class="content">
<form @submit="formSubmit" @reset="formReset">
<!-- leftTitle:左边标题 name:输入框名字 value:输入框值 placeholder:占位符 -->
<ccInputView leftTitle="姓名" name="name" value="" placeholder="请输入姓名"></ccInputView>
<!-- leftTitle:左边标题 name:输入框名字 value:输入框值 placeholder:占位符 -->
<ccInputView leftTitle="手机号" name="phone" value="" placeholder="请输入手机号"></ccInputView>
<ccInputView leftTitle="住址" name="address" value="" placeholder="请输入地址"></ccInputView>
<ccInputView leftTitle="爱好" name="interest" value="" placeholder="请输入爱好"></ccInputView>
<view class="uni-btn-v">
<button class="botBtn" type="primary" form-type="submit">下一步</button>
<view class="tipText"> 注意事项: 请确保您填写的信息真实无误 </view>
</view>
</form>
</view>
</template>
```
#### JS代码 (引入组件 填充数据)
```javascript
<script>
import ccInputView from '../../components/ccInputView.vue'
export default {
components:{
ccInputView
},
data() {
return {
}
},
methods: {
formSubmit: function(e) {
console.log('form发生了submit事件,携带数据为:' + JSON.stringify(e));
var formdata = e.detail.value;
uni.showModal({
title:'温馨提示',
content:'formsubmit事件携带数据为:' + JSON.stringify(e.detail.value)
})
},
towardPickerChange: function(e) {
this.towardIndex = e.target.value;
console.log(e.target.value);
},
floorPickerChange: function(e) {
this.floorIndex = e.target.value;
console.log(e.target.value);
},
liftPickerChange: function(e) {
this.liftIndex = e.target.value;
console.log(e.target.value);
},
decoratePickerChange: function(e) {
this.decorateIndex = e.target.value;
console.log(e.target.value);
},
}
}
</script>
```
#### CSS
```CSS
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.uni-btn-v{
width: 100%;
height: auto;
}
.botBtn {
width: 90%;
margin-top: 36px;
}
.tipText {
width: 100%;
margin-left: 0px;
text-align: center;
color: #666666;
margin-top: 36px;
margin-bottom: 36px;
font-size: 28rpx;
}
</style>
```