Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
lls_program
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-08-28 21:37:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
35dc0c8ab7b0868a88b586ce7ac1901e34fbd218
35dc0c8a
1 parent
32ef597f
feat(CreateFamily): 添加表单验证并禁用无效提交按钮
当表单未填写完整时禁用提交按钮并显示灰色样式,移除手动验证逻辑
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
src/pages/CreateFamily/index.vue
src/pages/CreateFamily/index.vue
View file @
35dc0c8
<!--
* @Date: 2025-08-27 17:44:53
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-28
12:55:42
* @LastEditTime: 2025-08-28
21:35:16
* @FilePath: /lls_program/src/pages/CreateFamily/index.vue
* @Description: 文件描述
-->
...
...
@@ -115,7 +115,7 @@
/>
<view
@click="deleteAvatar"
class="absolute -top-2 -right-2 w-
5 h-5
bg-red-500 rounded-full flex items-center justify-center"
class="absolute -top-2 -right-2 w-
4 h-4
bg-red-500 rounded-full flex items-center justify-center"
>
<view class="text-white text-xs">×</view>
</view>
...
...
@@ -140,8 +140,11 @@
</view>
<!-- Submit Button -->
<view
@click="handleCreateFamily"
class="w-full py-3 bg-blue-500 text-white text-lg font-medium rounded-lg flex items-center justify-center"
@tap="isFormValid ? handleCreateFamily : null"
:class="[
'w-full py-3 text-white text-lg font-medium rounded-lg flex items-center justify-center',
isFormValid ? 'bg-blue-500' : 'bg-gray-400'
]"
>
创建家庭
</view>
...
...
@@ -160,7 +163,7 @@
</template>
<script setup>
import { ref, nextTick } from 'vue';
import { ref, nextTick
, computed
} from 'vue';
import Taro from '@tarojs/taro';
import { Edit, Tips, Photograph } from '@nutui/icons-vue-taro';
// import AppHeader from '../../components/AppHeader.vue';
...
...
@@ -176,6 +179,14 @@ const familyAvatar = ref('');
const focusedIndex = ref(-1);
const inputRefs = ref([]);
const isFormValid = computed(() => {
return (
familyName.value.trim() !== '' &&
familyIntro.value.trim() !== '' &&
familyMotto.value.every(char => char.trim() !== '')
);
});
// 图片预览相关
const previewVisible = ref(false);
const previewImages = ref([]);
...
...
@@ -364,10 +375,6 @@ const validateForm = () => {
* 创建家庭
*/
const handleCreateFamily = () => {
if (!validateForm()) {
return;
}
// 在实际应用中,这里会调用API创建家庭
// 目前仅作为演示跳转到仪表盘页面
showToast('家庭创建成功', 'success');
...
...
Please
register
or
login
to post a comment