当前位置: 首页 > wzjs >正文

flash做ppt的模板下载网站有哪些谷歌商店下载官网

flash做ppt的模板下载网站有哪些,谷歌商店下载官网,企业应该如何进行网站推广,网站公安局备案 上海目录 前言1. 实战2. Demo 前言 🤟 找工作,来万码优才:👉 #小程序://万码优才/r6rqmzDaXpYkJZF 以下主要针对Demo讲解,从实战中的体会 何为命令式 何为声明式 命令式的体验,随时都会有提交的按钮&#xff…

目录

  • 前言
  • 1. 实战
  • 2. Demo

前言

🤟 找工作,来万码优才:👉 #小程序://万码优才/r6rqmzDaXpYkJZF

以下主要针对Demo讲解,从实战中的体会

何为命令式 何为声明式

  • 命令式的体验,随时都会有提交的按钮,但是点击提交才会显示不满足的条件!
    在这里插入图片描述
  • 声明式的体验,不满足条件时,按钮框是灰色的!
    在这里插入图片描述
  1. 命令式:
    提交逻辑复杂,需要异步校验(如服务端唯一性检查)
    表单字段多,依赖用户行为触发验证
    需要复用校验函数,或表单逻辑分散多处

  2. 声明式:
    表单简单明了
    用户体验优先,提前告知无法提交的情况
    状态可视化,一目了然

对比项命令式校验(方法中校验)声明式校验(computed + disabled 控制)
📋 方式在 submit() 方法内通过 validateForm() 显式校验通过 computed 计算属性实时判断是否可提交
🧠 编程范式命令式(Imperative)声明式(Declarative)
💡 表达方式手动控制流程:如果失败就 return false自动计算状态:按钮根据是否满足条件自动禁用
🔁 可复用性校验逻辑聚焦在 validateForm(),但要手动调用校验逻辑绑定在状态中,按钮等 UI 自动响应
🧪 用户体验用户点击“提交”后才提示不通过一目了然,提交按钮禁用,无法误触提交
⚙️ 灵活性可以灵活插入额外逻辑,如提交前弹窗确认逻辑适合纯状态驱动,复杂流程需另外处理
🪛 适用场景需要流程控制、嵌套逻辑、异步校验时更适合表单项简单明确、状态驱动时更适合

1. 实战

实战中抽取的Demo比较简易:

命令式 submit 校验方式(validateForm)

<template><button type="primary" @click="submit">提交</button>
</template><script>
export default {data() {return {imgCntrF: [],damPhotoList: []};},methods: {validateForm() {if (!this.imgCntrF.length) {uni.showToast({ title: '请拍摄箱门照片', icon: 'none' });return false;}if (this.damPhotoList.length < 2) {uni.showToast({ title: '请至少拍摄 2 张照片', icon: 'none' });return false;}return true;},async submit() {if (!this.validateForm()) return;// 执行提交逻辑console.log("提交成功");}}
}
</script>

声明式 computed 控制按钮状态

<template><button type="primary" :disabled="!canSubmit" @click="submit">提交</button>
</template><script>
export default {data() {return {photoList: {door: '',  // 对应 imgCntrFside: ''},damPhotoList: [],photoField: [{ key: 'door', label: '箱门照片' },{ key: 'side', label: '侧面照片' }]};},computed: {canSubmit() {return this.photoField.every(field => this.photoList[field.key]) &&this.damPhotoList.length >= 2;}},methods: {submit() {console.log("提交成功");}}
}
</script>

2. Demo

以UniApp( Vue2 语法 + script 写法)

命令式校验提交(Imperative)

<template><view class="container"><view class="section"><text>箱门照片:</text><button @click="selectBoxDoorPhoto">选择照片</button><image v-if="imgCntrF" :src="imgCntrF" class="img-preview" /></view><view class="section"><text>破损照片:</text><button @click="addDamPhoto">添加照片</button><view class="photo-list"><image v-for="(photo, index) in damPhotoList" :key="index" :src="photo" class="img-preview" /></view></view><button type="primary" @click="submit">提交</button></view>
</template><script>
export default {data() {return {imgCntrF: '', // 箱门照片 URLdamPhotoList: [] // 破损照片 URL 列表};},methods: {selectBoxDoorPhoto() {uni.chooseImage({count: 1,success: (res) => {this.imgCntrF = res.tempFilePaths[0];}});},addDamPhoto() {uni.chooseImage({count: 1,success: (res) => {this.damPhotoList.push(res.tempFilePaths[0]);}});},validateForm() {if (!this.imgCntrF) {uni.showToast({ title: '请拍摄箱门照片', icon: 'none' });return false;}if (this.damPhotoList.length < 2) {uni.showToast({ title: '请至少拍摄 2 张破损照片', icon: 'none' });return false;}return true;},submit() {if (!this.validateForm()) return;// 模拟提交成功uni.showToast({ title: '提交成功', icon: 'success' });}}
};
</script><style>
.container {padding: 20rpx;
}
.section {margin-bottom: 30rpx;
}
.img-preview {width: 200rpx;height: 200rpx;margin-top: 10rpx;
}
.photo-list {display: flex;flex-wrap: wrap;gap: 10rpx;
}
</style>

声明式按钮控制提交(Declarative)

<template><view class="container"><view class="section"><text>箱门照片:</text><button @click="selectBoxDoorPhoto">选择照片</button><image v-if="photoList.door" :src="photoList.door" class="img-preview" /></view><view class="section"><text>破损照片:</text><button @click="addDamPhoto">添加照片</button><view class="photo-list"><image v-for="(photo, index) in damPhotoList" :key="index" :src="photo" class="img-preview" /></view></view><button type="primary" :disabled="!canSubmit" @click="submit">提交</button></view>
</template><script>
export default {data() {return {photoList: {door: '' // 箱门照片},damPhotoList: []};},computed: {canSubmit() {return !!this.photoList.door && this.damPhotoList.length >= 2;}},methods: {selectBoxDoorPhoto() {uni.chooseImage({count: 1,success: (res) => {this.photoList.door = res.tempFilePaths[0];}});},addDamPhoto() {uni.chooseImage({count: 1,success: (res) => {this.damPhotoList.push(res.tempFilePaths[0]);}});},submit() {uni.showToast({ title: '提交成功', icon: 'success' });}}
};
</script><style>
.container {padding: 20rpx;
}
.section {margin-bottom: 30rpx;
}
.img-preview {width: 200rpx;height: 200rpx;margin-top: 10rpx;
}
.photo-list {display: flex;flex-wrap: wrap;gap: 10rpx;
}
</style>
http://www.dtcms.com/wzjs/184685.html

相关文章:

  • 做电商网站商标海外seo培训
  • 企业建站公司方案厨师培训机构
  • 成都网站建设 今网科技国内十大软件培训机构
  • 卡易售网站建设网页设计模板素材图片
  • 中国电商平台seo工作内容有哪些
  • seo免费浏览网站手机360优化大师官网
  • wordpress小程序后台seo没什么作用了
  • 我制作了一个网站seo的主要内容
  • 展示型网站设计乔拓云网微信小程序制作
  • 广东融都建设有限公司 公司网站软文优化
  • 漳州市建设局网站农产品网络营销
  • 网站建设成果网站关键词优化软件效果
  • 洛阳哪里做网站1688如何搜索关键词排名
  • 地产公司做网站维护写代码么6友情链接英文
  • 促销网站怎么做学校网站模板
  • 网站静态与动态看b站二十四小时直播间
  • 天河做网站企业作品推广
  • 长沙哪里优化网站贵州seo技术培训
  • 软文网站备案如何查询指数是什么意思
  • 南京手机app开发公司长春seo网站优化
  • html仿百度页面代码成都网站优化公司
  • 湘潭做网站 要到磐石网络帮收款的接单平台
  • 建设社区网站有什么借鉴之处深圳seo推广
  • 自己开发网站怎么开发关键词优化平台有哪些
  • 日本做音乐网站seo搜索优化怎么做
  • vc 做网站源码百度新闻首页
  • 公司装修装饰如何做网站搜索引擎优化
  • 做商城外贸网站上海热点新闻
  • 成都培训学校网站建设网络外贸推广
  • 网站如何做好优化seo营销是什么