Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
467ca202
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看板
提交
467ca202
编写于
11月 06, 2023
作者:
H
hdx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unicloud-db-contact: add页面 使用form组件获取表单提交数据
上级
72141cf4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
44 deletion
+36
-44
pages/component/unicloud-db-contacts/add.uvue
pages/component/unicloud-db-contacts/add.uvue
+36
-44
未找到文件。
pages/component/unicloud-db-contacts/add.uvue
浏览文件 @
467ca202
...
@@ -3,32 +3,34 @@
...
@@ -3,32 +3,34 @@
<unicloud-db ref="udb" v-slot:default="{error}" :collection="collection" loadtime="manual">
<unicloud-db ref="udb" v-slot:default="{error}" :collection="collection" loadtime="manual">
<view v-if="error!=null" class="error">{{error.errMsg}}</view>
<view v-if="error!=null" class="error">{{error.errMsg}}</view>
</unicloud-db>
</unicloud-db>
<view class="form-item">
<form @submit="onFormSubmit">
<text class="form-item-label">姓名</text>
<view class="form-item">
<input class="form-item-input" placeholder="姓名" v-model="username" />
<text class="form-item-label">姓名</text>
</view>
<input class="form-item-input" placeholder="姓名" name="username" />
<view class="form-item">
</view>
<text class="form-item-label">电话</text>
<view class="form-item">
<input class="form-item-input" placeholder="电话" v-model="mobile" />
<text class="form-item-label">电话</text>
</view>
<input class="form-item-input" placeholder="电话" name="mobile" />
<view class="form-item">
</view>
<text class="form-item-label">邮箱</text>
<view class="form-item">
<input class="form-item-input" placeholder="邮箱地址" v-model="email" />
<text class="form-item-label">邮箱</text>
</view>
<input class="form-item-input" placeholder="邮箱地址" name="email" />
<view class="form-item">
</view>
<text class="form-item-label">备注</text>
<view class="form-item">
<textarea class="form-item-input" placeholder="备注" v-model="comment" />
<text class="form-item-label">备注</text>
</view>
<textarea class="form-item-input" placeholder="备注" name="comment" />
<view class="form-item">
</view>
<text class="form-item-label">性别</text>
<view class="form-item">
<radio-group class="radio-list" @change="radioChange">
<text class="form-item-label">性别</text>
<view class="radio-item" v-for="(item, _) in genderList" :key="item.value">
<radio-group class="radio-list" name="gender">
<radio :value="item.value" :checked="item.value == gender" />
<view class="radio-item" v-for="(item, _) in genderList" :key="item.value">
<text>{{item.text}}</text>
<radio :value="item.value" />
</view>
<text>{{item.text}}</text>
</radio-group>
</view>
</view>
</radio-group>
<button class="btn-add" type="primary" @click="submit">保存</button>
</view>
<button class="btn-add" type="primary" form-type="submit">保存</button>
</form>
</view>
</view>
</template>
</template>
...
@@ -39,11 +41,6 @@
...
@@ -39,11 +41,6 @@
data() {
data() {
return {
return {
collection: COLLECTION_NAME,
collection: COLLECTION_NAME,
username: "",
mobile: "",
gender: "",
comment: "",
email: "",
genderList: GenderList as GenderType[],
genderList: GenderList as GenderType[],
$uniCloudElement: null as UniCloudDBElement | null
$uniCloudElement: null as UniCloudDBElement | null
}
}
...
@@ -52,19 +49,14 @@
...
@@ -52,19 +49,14 @@
this.$uniCloudElement = this.$refs['udb'] as UniCloudDBElement
this.$uniCloudElement = this.$refs['udb'] as UniCloudDBElement
},
},
methods: {
methods: {
radioChange(e : RadioGroupChangeEvent) {
// radioChange(e : RadioGroupChangeEvent) {
this.gender = e.detail.value
// this.gender = e.detail.value
},
// },
submit() {
onFormSubmit: function (e : FormSubmitEvent) {
const value = {
const formData = e.detail.value
username: this.username,
// TODO 待调整 <radio-group> <radio> value 属性为 any 后可省略此转换
gender: parseInt(this.gender),
formData['gender'] = parseInt(formData['gender'] as string)
mobile: this.mobile,
this.$uniCloudElement!.add(formData, {
comment: this.comment,
email: this.email,
};
this.$uniCloudElement!.add(value, {
showToast: false,
showToast: false,
needLoading: true,
needLoading: true,
loadingTitle: "正在保存...",
loadingTitle: "正在保存...",
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录