form.vue 2.4 KB
Newer Older
H
hulinNeil 已提交
1 2 3 4
<template>
	<view>
		<page-head :title="title"></page-head>
		<view class="page-body">
H
hulinNeil 已提交
5
			<form @submit="formSubmit" @reset="formReset">
H
hulinNeil 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
				<view class="page-section page-section-gap">
					<view class="page-section-title">switch</view>
					<switch name="switch" />
				</view>

				<view class="page-section page-section-gap">
					<view class="page-section-title">radio</view>
					<radio-group class="uni-flex" name="radio">
						<label>
							<radio value="radio1" />选项一</label>
						<label>
							<radio value="radio2" />选项二</label>
					</radio-group>
				</view>

				<view class="page-section page-section-gap">
					<view class="page-section-title">checkbox</view>
					<checkbox-group class="uni-flex" name="checkbox">
						<label>
							<checkbox value="checkbox1" />选项一</label>
						<label>
							<checkbox value="checkbox2" />选项二</label>
					</checkbox-group>
				</view>

				<view class="page-section page-section-gap">
					<view class="page-section-title">slider</view>
					<slider value="50" name="slider" show-value></slider>
				</view>

				<view class="page-section">
					<view class="page-section-title">input</view>
					<view class="uni-list">
						<view class="uni-list-cell uni-list-cell-pd">
							<input name="input" placeholder="这是一个输入框" />
						</view>
					</view>
				</view>

				<view class="btn-area">
					<button class="btn-submit" formType="submit">Submit</button>
					<button type="default" formType="reset">Reset</button>
				</view>
			</form>
		</view>
	</view>
</template>
<script>
	import pageHead from '../../../components/page-head.vue'

	export default {
		data() {
			return {
				title: 'form',
				pickerHidden: true,
				chosen: ''
			}
		},
		methods: {
			pickerConfirm: function (e) {
				this.pickerHidden = true
				this.chosen = e.target.value
			},
			pickerCancel: function (e) {
				this.pickerHidden = true
			},
			pickerShow: function (e) {
				this.pickerHidden = false
			},
			formSubmit: function (e) {
H
hulinNeil 已提交
76
				console.log('form发生了submit事件,携带数据为:' + JSON.stringify(e.detail.value))
H
hulinNeil 已提交
77 78
			},
			formReset: function (e) {
H
hulinNeil 已提交
79
				console.log("清空数据")
H
hulinNeil 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
				this.chosen = ''
			}
		},
		components: {
			pageHead

		}
	}
</script>

<style>
	@import "../../../common/uni.css";
	label {
		display: flex;
		flex-direction: row;
		min-width: 270px;
		margin-right: 20px;
	}

	.btn-submit {
		background-color: #007aff;
		color: #ffffff;
	}
</style>