Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

js 替换数组中的某个元素。

我用element做了个表格,增加我用push,删除用filter。编辑问题难到我了。

image.png

点击操作栏的 - 我就删除该行。

delArrt(item) {
  console.log(item,'itemitem')
    this.form2.link = this.form2.link.filter(val => {
    return val != item;
})},


增加

addArrt(data) {
  this.form2.link.push(
    { name: '',url: '',logo: ''}
    );
},

编辑其实只要在表格input里输入就可以了,但是图片这个我得上传,现在得思路是上传后的新Logo跟旧数据里得该logo调换。

因为我是数据库json转换过来得,没有id。所以不太好找。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

那就用index


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...