mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-21 22:09:16 +08:00
[new feature] Field: 增加 value 传入支持 (#60)
* field 支持 value 传入 * textarea 清除输入示例
This commit is contained in:
parent
12ace17fdc
commit
9c05bd2d58
@ -2,6 +2,8 @@ var Zan = require('../../dist/index');
|
||||
|
||||
Page(Object.assign({}, Zan.Field, {
|
||||
data: {
|
||||
value: 'test',
|
||||
textareaValue: 'test textarea',
|
||||
area: ['省份', '北京市', '天津市', '河北省', '山西省', '内蒙古自治区', '辽宁省', '吉林省', '黑龙江省', '上海市', '江苏省', '浙江省', '安徽省', '福建省', '江西省', '山东省', '河南省', '湖北省', '湖南省', '广东省', '广西壮族自治区', '海南省', '重庆市', '四川省', '贵州省', '云南省', '西藏自治区', '陕西省', '甘肃省', '青海省', '宁夏回族自治区', '新疆维吾尔自治区', '台湾省', '香港特别行政区', '澳门特别行政区'],
|
||||
areaIndex: 0
|
||||
},
|
||||
@ -16,5 +18,17 @@ Page(Object.assign({}, Zan.Field, {
|
||||
const { componentId, detail } = e;
|
||||
|
||||
console.log('[zan:field:change]', componentId, detail);
|
||||
},
|
||||
|
||||
clearInput() {
|
||||
this.setData({
|
||||
value: ''
|
||||
});
|
||||
},
|
||||
|
||||
clearTextarea() {
|
||||
this.setData({
|
||||
textareaValue: ''
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
@ -5,14 +5,22 @@
|
||||
|
||||
<view class="zan-panel-title">基础用法</view>
|
||||
<view class="zan-panel">
|
||||
<template is="zan-field" data="{{ title: '收货人', type: 'input', placeholder: '名字' }}"></template>
|
||||
<template is="zan-field" data="{{ title: '收货人', type: 'input', placeholder: '名字', value: value }}"></template>
|
||||
<template is="zan-field" data="{{ title: '联系电话', type: 'input', inputType: 'number', placeholder: '请输入手机号', error: true }}"></template>
|
||||
<template is="zan-field" data="{{ title: '详细地址', type: 'textarea', placeholder: '请输入详细地址' }}"></template>
|
||||
</view>
|
||||
|
||||
<view class="zan-btns">
|
||||
<button class="zan-btn zan-btn--primary" bindtap="clearInput">清除输入</button>
|
||||
</view>
|
||||
|
||||
<view class="zan-panel-title">无标题输入框</view>
|
||||
<view class="zan-panel">
|
||||
<template is="zan-field" data="{{ type: 'input', placeholder: '请输入收货人姓名' }}"></template>
|
||||
<template is="zan-field" data="{{ type: 'input', placeholder: '请输入收货人姓名', value: textareaValue }}"></template>
|
||||
</view>
|
||||
|
||||
<view class="zan-btns">
|
||||
<button class="zan-btn zan-btn--primary" bindtap="clearTextarea">清除输入</button>
|
||||
</view>
|
||||
|
||||
<view class="zan-panel-title field__title--radius">圆角输入框</view>
|
||||
|
@ -6,6 +6,7 @@
|
||||
<textarea
|
||||
wx:if="{{ type === 'textarea' }}"
|
||||
auto-height
|
||||
value="{{ value }}"
|
||||
placeholder="{{ placeholder }}"
|
||||
class="zan-field__input zan-cell__bd {{ right ? 'zan-field__input--right' : '' }}"
|
||||
placeholder-class="zan-field__placeholder"
|
||||
@ -14,6 +15,7 @@
|
||||
<input
|
||||
wx:else
|
||||
type="{{ inputType || 'text' }}"
|
||||
value="{{ value }}"
|
||||
placeholder="{{ placeholder }}"
|
||||
class="zan-field__input zan-cell__bd {{ right ? 'zan-field__input--right' : '' }}"
|
||||
placeholder-class="zan-field__placeholder"
|
||||
|
Loading…
x
Reference in New Issue
Block a user