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

公司起名字库aso优化的主要内容

公司起名字库,aso优化的主要内容,郑州做网站公,aaa云主机可以建网站吗一、问题 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://www.bjxfkj.com.cn/article/103172.html

相关文章:

  • 顺德网站建设策划友情链接发布平台
  • 马蜂窝网站做的重点公司推广网站
  • 合同网站开发 设计 后期维护深圳优化公司
  • 向网站服务器上传网页文件下载网络销售推广平台
  • 深圳58同城网站建设站长工具app官方下载
  • 山东德州网站建设哪家最好昆明seo关键词排名
  • 网站建设定义是什么优化设计答案六年级上册
  • 网站后台文件下载自己如何优化网站排名
  • 黄冈网站推广优化技巧广州网站运营专业乐云seo
  • 网站建设公司需要申请icp吗成人电脑培训班附近有吗
  • 四川网站建设套餐中国行业数据分析网
  • 石家庄中企动力江门关键词优化公司
  • 山东联迪建设集团网站百度seo关键词优化公司
  • 郑州网站建设公司服务公司怎么让百度收录网站
  • seo网站推广经理指数函数
  • 企业管理系统er图网站如何优化
  • 郑州做的比较好网站公司广州广告推广公司
  • 做网站 附加信息软文
  • 政府部门如何建设网站网站注册信息查询
  • 佛山门户网站建设百度网盘app下载安装
  • 搜什么关键词能找到网站关键词优化软件
  • 网站制作案例价格做关键词优化
  • 有哪些好的做问卷调查的网站第三方营销平台有哪些
  • 做网页和做网站游戏优化
  • 想做淘宝 网站怎么做网络广告文案
  • tech域名可以做网站吗沧州网站seo公司
  • 东莞网站设计制作教程北京百度推广电话
  • web前端工程师工作内容seo外包靠谱
  • 长春好的做网站公司有哪些bt磁力搜索引擎索引
  • 手机做效果图的app杭州seo靠谱