hookehuyr

✨ feat: 新增表单封面和表单描述

1 <!-- 1 <!--
2 * @Date: 2022-07-18 10:22:22 2 * @Date: 2022-07-18 10:22:22
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-09-06 14:41:04 4 + * @LastEditTime: 2022-09-06 15:05:23
5 * @FilePath: /data-table/src/views/index.vue 5 * @FilePath: /data-table/src/views/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
8 <template> 8 <template>
9 - <van-image width="100%" height="200" src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg" /> 9 + <van-image v-if="table_cover" width="100%" height="200" :src="table_cover" />
10 - <div style="padding: 1rem;">表单描述</div> 10 + <div v-if="table_title" class="table-title">{{ table_title }}</div>
11 - <div style="padding: 1rem;"> 11 + <div class="table-box">
12 <van-form @submit="onSubmit"> 12 <van-form @submit="onSubmit">
13 <van-cell-group> 13 <van-cell-group>
14 <component v-for="(item, index) in mockData" :key="index" :is="item.component" :item="item" /> 14 <component v-for="(item, index) in mockData" :key="index" :is="item.component" :item="item" />
...@@ -20,14 +20,18 @@ ...@@ -20,14 +20,18 @@
20 </div> 20 </div>
21 </van-form> 21 </van-form>
22 </div> 22 </div>
23 -
24 </template> 23 </template>
25 24
26 <script setup> 25 <script setup>
27 import { createComponentType } from '@/hooks/useComponentType' 26 import { createComponentType } from '@/hooks/useComponentType'
28 27
28 +const table_cover = ref('');
29 +const table_title = ref('');
29 const mockData = ref([]); 30 const mockData = ref([]);
31 +
30 onMounted(() => { 32 onMounted(() => {
33 + table_cover.value = 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg'
34 + table_title.value = '这是一个表单的描述'
31 mockData.value = [{ 35 mockData.value = [{
32 key: 'phone', 36 key: 'phone',
33 value: '', 37 value: '',
...@@ -165,4 +169,10 @@ const onSubmit = (values) => { ...@@ -165,4 +169,10 @@ const onSubmit = (values) => {
165 </script> 169 </script>
166 170
167 <style lang="less" scoped> 171 <style lang="less" scoped>
172 + .table-title {
173 + padding: 1rem;
174 + }
175 + .table-box {
176 + padding: 1rem;
177 + }
168 </style> 178 </style>
......