基于SqlSugar开发框架的基础上快速开发H5端的移动应用
<p>在开发一些项目的时候,我们往往会基于一定的框架进行业务的开发,并结合一些辅助工具进行更高效率的快速开发和整合工作,SqlSugar开发框架是我们开发的一个多端整合的开发框架,基于它的后端框架的WebAPI 基础上,我们可以对接WInform端、Vue3+ElementPlus的BS端,Vue3+Vant4的H5端,以及WPF、或者小程序等多端接入,本篇随笔介绍一个简单的项目录入功能,介绍基于SqlSugar开发框架的基础上快速开发H5端的移动应用。</p><h3>1、设计数据库</h3>
<p>俗话说万层高楼从底起,开发应用项目,数据库的设计很重要,它可能是业务对象,业务流程的综合设计,好的数据库设计可以减少后期的重复返工,提高开发效率。</p>
<p>一般表名称,根据不同的业务关系,我们可以使用不同的前缀进行区分,使用前缀,可以非常方便区分不同的业务表,如我自己一般基础表使用 “TB_” 定义前缀,权限系统表使用"T_ACL_"定义前缀,工作流表使用“TBAPP_”,业务表使用"T_"等,这样对于区分不同的业务,方便管理很有好处。</p>
<p>字段名称方面,我们可以约定一些规则,如约定主键使用ID;一般来说,ID作为主键,可以使用自增长的整形字段,也可以使用GUID的字符型字段,如果为了方便兼容不同的数据库且方便迁移或者开发基于网络方面的应用,我建议还是使用GUID的字符型字段,使用这种类型的字段,我们从创建数据的时候,就可以知道这个记录的主键,对于我们维护父子表等关系非常有利。</p>
<p>由于如果采用字符型的ID主键,那么我们如果需要正确排序的时候,可能需要增加一个CreateTime的日期类型,方便我们根据日期进行排序,或者特定的需要增加一个SortOrder字段。</p>
<p>如果这个表还有一个外键的引用,建议统一命名标准,我一般使用“表名称_ID这样的名称,如User_ID、Contact_ID等相似的名称作为外键,不需要表的前缀。</p>
<p>数据库的模型设计,我们建议在第三方的数据库设计工具上进行设计,如PowerDesigner这样的设计工具,使用工具设计数据库有很多好处,一个是可以高效率进行调整,二是根据需要生成不同的数据库类型Sql语句,三是可以全局了解各个表之间的关系等等。</p>
<p>使用PowerDesigner这样的数据库设计工具,能够在很大程度上提高我们数据库的设计效率。我们默认以SQLServer数据库创建表,如下所示。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230115810545-678368233.png" alt="image" width="323" height="278" loading="lazy"></p>
<p>设计好的数据表,在设计状态下,添加相关的备注信息。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230115835170-756890014.png" alt="image" width="796" height="467" loading="lazy"></p>
<p> 然后生成相关的SQL代码,我们就可以再具体的数据库管理工具上执行创建对应的表信息了。 </p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230115908156-1344039466.png" alt="image" width="794" height="466" loading="lazy"></p>
<p> 完成数据库表创建后,我们就完成了第一阶段的工作了。</p>
<p> </p>
<h3>2、生成SqlSugar开发框架的后端基础代码并整合</h3>
<p>设计好数据库后,我们通过代码生成工具进行基于项目框架的代码生成,这样对于我们在开发新项目上有很好的好处,里面的项目层级、引用关系,已经处理好了,这样对我们非常方便。</p>
<p>不过大多数情况下,我们都是增量开发较多,也就是我们可能前面已经完成了一些其他业务的开发,可能新增一个两个表,或者一批业务表的处理,我们生成相关的代码文件后把它们复制到项目恰当位置上即可。</p>
<p>由于项目生成的时候,指定了主命名空间和相关的表前缀,这样我们生成后的代码就方便阅读很多,减少累赘和出错的机会。</p>
<p>利用代码生成工具Database2Sharp强大的数据库元数据和模板引擎,我们构建了对应的框架代码生成规则,因此统一生成即可,提高了代码开发的效能,同时也统一了代码的结构,便于大项目的维护。</p>
<p>对于SQLSugar的项目框架,我们为了方便,分别单独提供后端代码和Web API代码的生成、Winform界面代码的生成,以及前面介绍到的Vue3+TypeScript+ElementPlus的代码生成操作。</p>
<p>代码生成工具的界面效果如下所示,通过入口菜单,可以实现不同部分的代码快速生成。我们先使用【Sqlsugar框架代码生成】生成后端的相关代码文件。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230125345005-735899731.png" alt="image" width="1033" height="636" loading="lazy"></p>
<p>选择我们刚才创建的表进行一步步的生成即可。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230142927634-577910459.png" alt="image" width="534" height="406" loading="lazy"></p>
<p>生成代码,我们可以看到相关的目录,如下所示。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230143200345-246629280.png" alt="image" width="850" height="591" loading="lazy"></p>
<p>复制整合文件到框架项目的合适位置上,暂时不需要增加任何方法代码,我们利用继承的基类方法就完全满足需求 。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230151121521-1088455216.png" alt="image" width="1017" height="964" loading="lazy"></p>
<p> </p>
<h3>3、基于Vant4+Vue3+TypeScript的H5移动前端进行开发</h3>
<div><strong>关于Vant4</strong></div>
<div>
<p>Vant 是一个<strong>轻量、可定制的移动端组件库</strong>,于 2017 年开源。目前 Vant 官方提供了 Vue 2 版本、Vue 3 版本和微信小程序版本,并由社区团队维护 React 版本和支付宝小程序版本。</p>
<p>当前移动端 项目采用最新的Vant4进行开发,适合于Vue3的项目开发。</p>
<p>Vant 4 是一款基于 Vue 3 的轻量、可靠的手机端组件库,主要用于快速搭建移动端应用。它提供了许多常用的 UI 组件,如按钮、卡片、表单、导航等,旨在帮助开发者提高开发效率,同时保持应用的性能和一致性。</p>
<p>Vant 4 是完全基于 Vue 3 构建的,充分利用了 Vue 3 的新特性和性能优化,如 Composition API、Teleport、Fragments 等。通过 Vue 3 的优化,Vant 4 在渲染性能上有了显著提升,特别是在处理大型列表和复杂组件时。</p>
<p><img src="https://www.iqidi.com/Framework/images/vant-mobile.png" alt="移动端H5应用" width="296" height="296"></p>
<p> 扫码进行了解 Vant4+Vue3+TypeScript 的移动前端。</p>
<p> </p>
</div>
<p>接下来就是针对H5端应用进行的界面开发了,我们可以参考案例的滚动到底部进行分页处理的页面案例,对内容进行分页展示处理,如下所示是几个界面的效果。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230144121321-490674470.png" alt="image" width="346" height="741" loading="lazy"> <img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230144148794-1515596057.png" alt="image" width="346" height="742" loading="lazy"> <img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230144313426-902219873.png" alt="image" width="346" height="741" loading="lazy"></p>
<p> 签名图片,我们通过调用通用的文件上传处理,把它上传到服务端的目录上了,使用的时候直接用其对应的地址即可。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230144611192-2014570350.png" alt="image" width="686" height="334" loading="lazy"></p>
<p>了解了界面效果,我们来看看具体的代码实现过程。</p>
<p>我们首先增加或者使用代码生成工具生成一个api对接后端的文件,如下所示。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230144808470-1588794631.png" alt="image" loading="lazy"></p>
<p>这个文件很简单,就是继承基类即可,不需要增加任何自定义方法。</p>
<div class="cnblogs_code">
<pre>import type { ListResult, PagedResult } from '@/api/types'<span style="color: rgba(0, 0, 0, 1)">
import BaseApi from </span>'@/api/base-api'<span style="color: rgba(0, 0, 0, 1)">
import { CommonResult } from </span>'@/api/types'<span style="color: rgba(0, 0, 0, 1)">
import { http } from </span>'@/utils/http/axios'
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 导入API基类对象,默认具有Get/GetAll/Create/Update/Delete/BatchDelete/SaveImport/Count等接口</span><span style="color: rgba(0, 128, 0, 1)">
//</span><span style="color: rgba(0, 128, 0, 1)"> 业务类自定义接口实现, 通用的接口已经在BaseApi中定义</span>
<span style="color: rgba(0, 0, 0, 1)">class Api <span style="color: rgba(255, 0, 0, 1)"><strong>extends BaseApi</strong></span> {
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 参考下面案例,增加自定义函数</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> GET 方法例子</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 根据条件计算记录数量</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> async GetCount(params: object) {</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> return await this.HttpGet<number>(this.baseurl + "count", params);</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> }</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> POST 方法例子</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 创建对象</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> async Create(data: object) {</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> return await this.HttpPost<boolean>(this.baseurl + `create`, data);</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> }</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> PUT 方法例子</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 更新对象</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> async Update(data: object) {</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> return await this.HttpPut<boolean>(this.baseurl + `update`, data);</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> }</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> DELETE 方法例子</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 删除指定ID的对象</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> async Delete(id: number | string) {</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> return await this.HttpDelete<boolean>(this.baseurl + `${id}`);</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> }</span>
<span style="color: rgba(0, 0, 0, 1)">}
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 构造测试工作项目 Api实例,并传递业务类接口地址</span>
export <span style="color: rgba(0, 0, 255, 1)">default</span> <span style="color: rgba(0, 0, 255, 1)">new</span> Api('<span style="color: rgba(255, 0, 0, 1)"><strong>/api/testworkitem/</strong></span>')</pre>
</div>
<p>前端根据框架后端的接口进行前端JS端的类的封装处理,引入了ES6类的概念实现业务基类接口的统一封装,简化代码。这些类继承BaseApi,就会具有相关的接口了,如下所示继承关系。</p>
<p><img src="https://img2020.cnblogs.com/blog/8867/202007/8867-20200713152737929-890201160.png" alt="" class="medium-zoom-image" loading="lazy"></p>
<p>我们已经在BaseApi的ES6类里面定义了对应Web API基类里面的操作方法,如下所示。</p>
<p><img src="https://img2022.cnblogs.com/blog/8867/202207/8867-20220707112405599-7103386.png" alt="" width="966" height="595" class="medium-zoom-image" loading="lazy"></p>
<p> 这样,我们在创建一个业务类的时候,如果没有特殊的自定义接口,只需要继承基类BaseApi即可具有所有的常规基类方法了。</p>
<p> 由于我们的ES6接口定义,是基于TypeScript的,它的数据类型可以推断出来,因此在编码或者查看对应属性的时候,会有非常好的提示信息。</p>
<p>对应几个不同的页面场景,我们分别创建不同的视图文件,如下所示。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230145310033-599021859.png" alt="image" width="479" height="454" loading="lazy"></p>
<p> 由于Vue3+Typescript+Vant4的H5应用端是基于VueRouter的路由处理,因此,我们需要在路由模块中增加对应的路由定义,如下所示。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230145553832-1840777761.png" alt="image" width="1065" height="863" loading="lazy"></p>
<p> 最后我们就可以再主页面提供一个入口,访问当前的模块了。如我们在列表页面模块中,首先需要引入对应的API调用类,以及定义对应的实体对象。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230145818721-1359007905.png" alt="image" width="1073" height="833" loading="lazy"></p>
<p> 页面只需要调用BaseApi的基类封装函数即可实现滚动继续分页获取记录的处理。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230150032578-1409793504.png" alt="image" width="1078" height="1309" loading="lazy"></p>
<p> 结合Vant4的相关控件,我们可以把记录的内容展示出来。</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">div </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="scroll-container"</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">page-header </span><span style="color: rgba(255, 0, 0, 1)">@click</span><span style="color: rgba(0, 0, 255, 1)">="goback"</span> <span style="color: rgba(0, 0, 255, 1)">/></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-search </span><span style="color: rgba(255, 0, 0, 1)">v-model</span><span style="color: rgba(0, 0, 255, 1)">="searchValue"</span><span style="color: rgba(255, 0, 0, 1)"> placeholder</span><span style="color: rgba(0, 0, 255, 1)">="请输入搜索关键词"</span><span style="color: rgba(255, 0, 0, 1)"> @search</span><span style="color: rgba(0, 0, 255, 1)">="onSearch"</span><span style="color: rgba(255, 0, 0, 1)"> @clear</span><span style="color: rgba(0, 0, 255, 1)">="clearInput"</span> <span style="color: rgba(0, 0, 255, 1)">/></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-list
</span><span style="color: rgba(255, 0, 0, 1)">v-model:loading</span><span style="color: rgba(0, 0, 255, 1)">="loading"</span><span style="color: rgba(255, 0, 0, 1)">
:finished</span><span style="color: rgba(0, 0, 255, 1)">="finished"</span><span style="color: rgba(255, 0, 0, 1)">
finished-text</span><span style="color: rgba(0, 0, 255, 1)">="没有更多了"</span><span style="color: rgba(255, 0, 0, 1)">
@load</span><span style="color: rgba(0, 0, 255, 1)">="onRefresh"</span>
<span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-swipe-cell
</span><span style="color: rgba(255, 0, 0, 1)">v-for</span><span style="color: rgba(0, 0, 255, 1)">="(item, index) in list"</span><span style="color: rgba(255, 0, 0, 1)">
:key</span><span style="color: rgba(0, 0, 255, 1)">="index"</span><span style="color: rgba(255, 0, 0, 1)">
class</span><span style="color: rgba(0, 0, 255, 1)">="m-2 overflow-hidden border border-gray-300 rounded-"</span>
<span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 128, 0, 1)"><!--</span><span style="color: rgba(0, 128, 0, 1)"> 主体内容 </span><span style="color: rgba(0, 128, 0, 1)">--></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">#default</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">div </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="box-border min-w-0 w-full flex flex-row items-start p-2"</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 128, 0, 1)"><!--</span><span style="color: rgba(0, 128, 0, 1)"> 图片区域 </span><span style="color: rgba(0, 128, 0, 1)">--></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-image
</span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="h- w- flex-shrink-0 rounded-md"</span><span style="color: rgba(255, 0, 0, 1)">
fit</span><span style="color: rgba(0, 0, 255, 1)">="contain"</span><span style="color: rgba(255, 0, 0, 1)">
:src</span><span style="color: rgba(0, 0, 255, 1)">="!isNullOrUnDef(item.creatsign) ? item.creatsign : '/images/img_nodata.png'"</span>
<span style="color: rgba(0, 0, 255, 1)">/></span>
<span style="color: rgba(0, 128, 0, 1)"><!--</span><span style="color: rgba(0, 128, 0, 1)"> 文本区域 </span><span style="color: rgba(0, 128, 0, 1)">--></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">div
</span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="ml-4 min-w-0 flex-1"</span><span style="color: rgba(255, 0, 0, 1)">
@click</span><span style="color: rgba(0, 0, 255, 1)">="showDetail(item.id ?? '')"</span>
<span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">div </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="whitespace-normal break-words text-base font-medium"</span><span style="color: rgba(0, 0, 255, 1)">></span><span style="color: rgba(0, 0, 0, 1)">
{{ item.item1 }}/{{ item.item2 }}/{{ item.item3 }}/{{ item.item4 }}
</span><span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">div</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">div </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="mt-2 flex flex-col whitespace-normal break-words text-sm text-gray-500"</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">span</span><span style="color: rgba(0, 0, 255, 1)">></span><span style="color: rgba(0, 0, 0, 1)">
状态:
</span><span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-tag </span><span style="color: rgba(255, 0, 0, 1)">:type</span><span style="color: rgba(0, 0, 255, 1)">="getStatusTag(item.status ?? 0)"</span><span style="color: rgba(0, 0, 255, 1)">></span><span style="color: rgba(0, 0, 0, 1)">
{{ getStatus(item.status) }}
</span><span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">van-tag</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">span</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">span</span><span style="color: rgba(0, 0, 255, 1)">></span>{{ format(item.createtime) }}<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">span</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">div</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">div</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">div</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 128, 0, 1)"><!--</span><span style="color: rgba(0, 128, 0, 1)"> 删除按钮 </span><span style="color: rgba(0, 128, 0, 1)">--></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">#right</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">div </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="h-full w- flex items-center justify-center bg-red-500"</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-icon </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="delete"</span><span style="color: rgba(255, 0, 0, 1)"> color</span><span style="color: rgba(0, 0, 255, 1)">="#fff"</span><span style="color: rgba(255, 0, 0, 1)"> size</span><span style="color: rgba(0, 0, 255, 1)">="20"</span><span style="color: rgba(255, 0, 0, 1)"> @click</span><span style="color: rgba(0, 0, 255, 1)">="deleteItem(item)"</span> <span style="color: rgba(0, 0, 255, 1)">/></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">div</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">van-swipe-cell</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">van-list</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-action-bar </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="m-2"</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-action-bar-icon </span><span style="color: rgba(255, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">="返回"</span><span style="color: rgba(255, 0, 0, 1)"> icon</span><span style="color: rgba(0, 0, 255, 1)">="arrow-left"</span><span style="color: rgba(255, 0, 0, 1)"> @click</span><span style="color: rgba(0, 0, 255, 1)">="goback"</span> <span style="color: rgba(0, 0, 255, 1)">/></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-action-bar-button </span><span style="color: rgba(255, 0, 0, 1)">color</span><span style="color: rgba(0, 0, 255, 1)">="green"</span><span style="color: rgba(255, 0, 0, 1)"> text</span><span style="color: rgba(0, 0, 255, 1)">="创建工作项目"</span><span style="color: rgba(255, 0, 0, 1)"> @click</span><span style="color: rgba(0, 0, 255, 1)">="createItem"</span> <span style="color: rgba(0, 0, 255, 1)">/></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">van-action-bar</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">div </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="mb-20"</span> <span style="color: rgba(0, 0, 255, 1)">/></span>
<span style="color: rgba(0, 0, 255, 1)"><</span><span style="color: rgba(128, 0, 0, 1)">van-back-top </span><span style="color: rgba(0, 0, 255, 1)">/></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">div</span><span style="color: rgba(0, 0, 255, 1)">></span>
<span style="color: rgba(0, 0, 255, 1)"></</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">></span></pre>
</div>
<p>从而实现了我们前面介绍的页面效果。</p>
<p><img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230144121321-490674470.png" alt="image" width="346" height="741" loading="lazy"> <img src="https://img2024.cnblogs.com/blog/8867/202512/8867-20251230150350899-1651155846.png" alt="image" width="348" height="746" loading="lazy"></p>
<p> 其他页面的效果也是类似,参考相关的界面实现来调整展示效果即可,不在赘述。</p>
<p> 如需进一步了解H5应用端的功能介绍,可以参考随笔《基于Vant4+Vue3+TypeScript的H5移动前端》,进行深入的了解。</p>
</div>
<div id="MySignature" role="contentinfo">
<div style="border-right-color: #cccccc; border-right-width: 1px; border-right-style: solid; padding-right: 5px; border-top-color: #cccccc; border-top-width: 1px; border-top-style: solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; width: 98%; padding-top: 4px; border-bottom-color: #cccccc; border-bottom-width: 1px; border-bottom-style: solid; background-color: #eeeeee;">
<img src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" alt>
<span style="color: #000000"><span class="Apple-tab-span" style="white-space: pre"></span>
专注于代码生成工具、.Net/Python 框架架构及软件开发,以及各种Vue.js的前端技术应用。著有Winform开发框架/混合式开发框架、微信开发框架、Bootstrap开发框架、ABP开发框架、SqlSugar开发框架、Python开发框架等框架产品。
<br> 转载请注明出处:撰写人:伍华聪 http://www.iqidi.com <br> </span></div><br><br>
来源:https://www.cnblogs.com/wuhuacong/p/19420561
頁:
[1]