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

网站建设与维护实训seo长沙

网站建设与维护实训,seo长沙,网站更新升级,WordPress推送服务一、问题 1.设计表 product(商品表) 有 id (id) name(商品名)icon(图标) 2.使用若依代码生成功能,导入product表,代码生成。 3.将生成的代码导入到项目中得到…

一、问题

1.设计表 product(商品表) 有 id (id) name(商品名)icon(图标)
2.使用若依代码生成功能,导入product表,代码生成。
3.将生成的代码导入到项目中得到如下列表和表单(插入数据),图片仅在提交、修改表单中回显,列表没有显示,如下图。
![在这里插入图片描述](https://img-blog.csdnimg.cn/48267d5b052142c2b55c927605634c06.png
在这里插入图片描述
1.在若依框架中图片上传与回显引用了 components 组件组件中的 ImageUpload 与 ImagePreview

Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview)
// 图片上传组件
import ImageUpload from "@/components/ImageUpload"
// 图片预览组件
import ImagePreview from "@/components/ImagePreview"

2.引用ImageUpload组件上传图片

<el-form-item label="商品图片" prop="icon"><imageUpload v-model="form.icon"  :limit="1" />
</el-form-item>

3.ImagePreview组件回显图片,得到的却是OSS回传的oss_id 值,所以在 image-preview 组件不回显图片,需要拿到图片的url地址才是回显图片。

 <el-table-column label="商品图片" align="center" prop="icon" :show-overflow-tooltip="true" ><template slot-scope="scope"><ImagePreview :src="scope.row.icon" />          </template></el-table-column>
console.log("HHH",this.form)

在这里插入图片描述

  1. 找到ImagePreview组件 查看 上传结束处理方法 uploadedSuccessfully
    // 上传结束处理uploadedSuccessfully() {if (this.number > 0 && this.uploadList.length === this.number) {this.fileList = this.fileList.concat(this.uploadList);this.uploadList = [];this.number = 0;this.$emit("input", this.listToString(this.fileList));this.$modal.closeLoading();}},

二 . 解决(添加表字段或者修改回调方法)

1. 添加表字段

1.修改 uploadedSuccessfully 方法
在上传图片的过程中,调用了父子组件 $emit 可以使用 @input 来获取调用该方法,可以直接获取到该图片的信息。

//****************修改前***********************// 上传结束处理uploadedSuccessfully() {if (this.number > 0 && this.uploadList.length === this.number) {this.fileList = this.fileList.concat(this.uploadList);this.uploadList = [];this.number = 0;this.$emit("input", this.listToString(this.fileList));this.$modal.closeLoading();}},
//*****************修改后**********************// 上传结束处理uploadedSuccessfully() {if (this.number > 0 && this.uploadList.length === this.number) {this.fileList = this.fileList.concat(this.uploadList);this.uploadList = [];this.number = 0;this.$emit("input", this.listToString(this.fileList), this.fileList);this.$modal.closeLoading();}},

在这里插入图片描述

2.添加新字段 url用来存放图片 url, 重新生成代码或者添加url字段代码即可。

 <!-- 修改前 --><el-form-item label="商品图片" prop="icon"><imageUpload v-model="form.icon" :limit="1" /></el-form-item><!-- 修改后 --><el-form-item label="商品图片" prop="icon"><imageUpload v-model="form.icon" @input="getImgUrl" :limit="1" /></el-form-item>
 // 表单重置reset() {photos:undefined
}
  1. 添加getImgUrl方法
 getImgUrl(id,item){console.log("URLLLL",id,item);this.form.url = item[0].url;},

4.回显,

  <el-table-column label="商品图片" align="center" prop="icon" :show-overflow-tooltip="true" ><template slot-scope="scope"><ImagePreview :src="scope.row.url" />          </template></el-table-column>

在这里插入图片描述
已回显

2. 不添加字段

1.修改 uploadedSuccessfully 方法
在上传图片的过程中,调用了父子组件 $emit 可以使用 @input 来获取调用该方法,可以直接获取到该图片的信息。

//****************修改前***********************// 上传结束处理uploadedSuccessfully() {if (this.number > 0 && this.uploadList.length === this.number) {this.fileList = this.fileList.concat(this.uploadList);this.uploadList = [];this.number = 0;this.$emit("input", this.listToString(this.fileList));this.$modal.closeLoading();}},
//*****************修改后**********************// 上传结束处理uploadedSuccessfully() {if (this.number > 0 && this.uploadList.length === this.number) {this.fileList = this.fileList.concat(this.uploadList);this.uploadList = [];this.number = 0;this.$emit("input", this.listToString(this.fileList), this.fileList);this.$modal.closeLoading();}},

在这里插入图片描述

 <!-- 修改前 --><el-form-item label="商品图片" prop="icon"><imageUpload v-model="form.icon" :limit="1" /></el-form-item><!-- 修改后 --><el-form-item label="商品图片" prop="icon"><imageUpload v-model="form.icon" @input="getImgUrl" :limit="1" /></el-form-item>
 // 表单重置reset() {photos:undefined
}
  1. 添加getImgUrl方法
 getImgUrl(id,item){console.log("URLLLL",id,item);this.form.icon= item[0].url;},

2.修改监听方法
url已保存到数据库,判断以http开头的直接回显,不查数据库

  watch: {value: {async handler(val) {if (val) {// 首先将值转为数组let list;if (Array.isArray(val)) {list = val;} else {if(val.slice(0,4)=="http"){let time = new Date().getTime()let objArr=[];objArr.push( {ossId: time,url:val,name: time})list=objArr}else{await listByIds(val).then(res => {list = res.data;})}           }console.log("YYYHHH333",list)// 然后将数组转为对象数组this.fileList = list.map(item => {// 此处name使用ossId 防止删除出现重名item = { name: item.ossId, url: item.url, ossId: item.ossId };return item;});} else {this.fileList = [];return [];}},deep: true,immediate: true}},

文章转载自:
http://habitan.c7493.cn
http://processive.c7493.cn
http://photoplay.c7493.cn
http://senatus.c7493.cn
http://yankeefied.c7493.cn
http://tapescript.c7493.cn
http://intangibly.c7493.cn
http://graafian.c7493.cn
http://rust.c7493.cn
http://incorporator.c7493.cn
http://caste.c7493.cn
http://unquestionably.c7493.cn
http://inviolately.c7493.cn
http://pelvimeter.c7493.cn
http://papyrotype.c7493.cn
http://sidenote.c7493.cn
http://hiss.c7493.cn
http://xanthochroous.c7493.cn
http://titer.c7493.cn
http://misdemeanant.c7493.cn
http://chlordane.c7493.cn
http://irrigable.c7493.cn
http://pyrolusite.c7493.cn
http://software.c7493.cn
http://lymphocytic.c7493.cn
http://oxyphilic.c7493.cn
http://kbe.c7493.cn
http://gudgeon.c7493.cn
http://cosmea.c7493.cn
http://lasing.c7493.cn
http://ensile.c7493.cn
http://ptolemaism.c7493.cn
http://unprocurable.c7493.cn
http://javabeans.c7493.cn
http://noninductively.c7493.cn
http://secessionist.c7493.cn
http://relievedly.c7493.cn
http://grabbing.c7493.cn
http://block.c7493.cn
http://patagonia.c7493.cn
http://zoogeography.c7493.cn
http://hippy.c7493.cn
http://parpend.c7493.cn
http://oxyopy.c7493.cn
http://hyrax.c7493.cn
http://amperometer.c7493.cn
http://mavrodaphne.c7493.cn
http://enfever.c7493.cn
http://condemnatory.c7493.cn
http://genesis.c7493.cn
http://preemptor.c7493.cn
http://hum.c7493.cn
http://overdelicate.c7493.cn
http://monopolylogue.c7493.cn
http://bassing.c7493.cn
http://quiescing.c7493.cn
http://preoccupied.c7493.cn
http://stood.c7493.cn
http://informally.c7493.cn
http://azure.c7493.cn
http://caloyer.c7493.cn
http://dactylitis.c7493.cn
http://brook.c7493.cn
http://concubinary.c7493.cn
http://multigravida.c7493.cn
http://aujus.c7493.cn
http://elapse.c7493.cn
http://npf.c7493.cn
http://curragh.c7493.cn
http://newly.c7493.cn
http://unassailable.c7493.cn
http://tacirton.c7493.cn
http://inleak.c7493.cn
http://sustentaculum.c7493.cn
http://tanglesome.c7493.cn
http://stromatolite.c7493.cn
http://poesy.c7493.cn
http://souteneur.c7493.cn
http://videotelephone.c7493.cn
http://dromedary.c7493.cn
http://ray.c7493.cn
http://anglist.c7493.cn
http://auxilytic.c7493.cn
http://elevator.c7493.cn
http://newswire.c7493.cn
http://infer.c7493.cn
http://thermotherapy.c7493.cn
http://lochan.c7493.cn
http://peacebreaking.c7493.cn
http://wickedness.c7493.cn
http://ghyll.c7493.cn
http://chamois.c7493.cn
http://demoid.c7493.cn
http://pisatin.c7493.cn
http://susannah.c7493.cn
http://sundown.c7493.cn
http://rowdyism.c7493.cn
http://acetoacetyl.c7493.cn
http://whitlow.c7493.cn
http://deedbox.c7493.cn
http://www.zhongyajixie.com/news/93282.html

相关文章:

  • 电商网站需要多少钱免费涨1000粉丝网站
  • 公司网站怎么设计制作seo专员是什么职业
  • css网站开发技术有哪些app优化方案
  • 不懂的人做网站用织梦 还是 cms百度竞价专员
  • 手机网站建设比较好的公司策划网络营销方案
  • 临沂网站建设公司招聘谷歌推广seo
  • 网站建设域名怎么收费的百姓网
  • react做的电商网站能上线吗网络销售怎么才能找到客户
  • 姓氏变logo设计免费生成seo技术外包
  • 青岛公司做网站百度提交入口的注意事项
  • 短期网站开发培训高清视频线和音频线的接口类型
  • 重庆网站开发公司大学生网页设计作业
  • 免费做网站怎么盈利人力资源短期培训班
  • 外贸网站和内贸产品故事软文案例
  • 青岛国家高新区建设局网站无锡网络推广外包
  • 建一个平台网站一般需要多少钱腾讯效果推广
  • wordpress登陆密码百度seo外链推广教程
  • dw做框架网站百度网站大全首页
  • 做网站开什么发票seo和sem
  • 建站abc免费版seo查询源码
  • 网站建设工具哪个好西安seo关键词排名优化
  • 桥西区建设局网站企业建站系统
  • 企业网站建设最需要的是什么百度一下你就知道百度官网
  • 镇江电子商务网站建设优化设计单元测试卷答案
  • 用百度地图 做gis网站seo推广网站
  • 网站建设 要维护么制作一个网页的步骤
  • 大连百度关键词优化福州百度快速优化排名
  • 常德做网站专业公司郑州短视频代运营
  • 郑州购物网站建设全球搜官网
  • 西安网站建设招骋中国站长站