这个是前端页面的调用代码
<template>
<uni-popup ref="add" type="center" :isMaskClick="false">
<uni-forms ref="form" v-model="data.formData" :rules="data.rules" class="form">
<uni-forms-item name="name" label="名称:">
<uni-easyinput placeholder="请输入名称" v-model="data.formData.name" trim="both"></uni-easyinput>
</uni-forms-item>
<view style="display: flex;">
<button type="primary" @click="confirm" size="mini" :loading="data.loading">确定</button>
<button type="primary" @click="hide" plain size="mini">取消</button>
</view>
</uni-forms>
</uni-popup>
</template>
<script setup>
import {
getCurrentInstance,
onMounted,
reactive
} from "vue"
import {
onLoad,
onShow,
onHide
} from "@dcloudio/uni-app"
const db = uniCloud.database()
const dbCollectionName = 'rent_shop-category'
const data = reactive({
id: '',
loading: false,
formData: {
name: ''
},
rules: {
name: {
rules: [{
required: true,
errorMessage: '请输入名称'
}],
validateTrigger: 'submit'
}
}
})
const {
proxy,
emit
} = getCurrentInstance()
onMounted(() => {
})
onLoad((res) => {
})
onShow(() => {
})
onHide(() => {
})
function show(para = {}) {
data.id = para.id
data.formData.name = para.name
proxy.$refs.add.open()
}
function hide() {
proxy.$refs.add.close()
}
function confirm() {
proxy.$refs.form.validate().then(values => {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).add(values).then((res) => {
uni.showToast({
title: '新增成功'
})
emit('confirm')
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
})
}
defineExpose({
show,
hide
})
</script>
<style lang="scss" scoped>
.form {
background-color: white;
border-radius: 12px;
padding: 20px;
width: 300px;
}
</style>
5***@qq.com (作者)
前端操作的,代码如下
同时我在JQL调试器中使用也无法触发
2023-06-26 13:15
DCloud_uniCloud_VK
回复 5***@qq.com: JQL调试器中本身就不会触发的, 那你上传下触发器
2023-06-26 14:04
5***@qq.com (作者)
回复 DCloud_uniCloud_VK: 触发器已经上传了,在云端数据库的schema扩展里面可以看到
2023-06-26 16:25
觅兔先生
我在unicloud-db中触发 触发器,docId拿不到
2023-12-05 01:15