html select嵌入table,el-table 嵌套 el-select

数据格式

{

"code": 200,

"message": "成功",

"data": {

"taskList": [{

"taskId": 17,

"taskModelPath": null,

"userId": 1,

"word": "测试一下",

"taskStatus": 1,

"recordFileNameArray": "[\"1_11_17_record1.wav\",\"1_11_17_record2.wav\",\"1_11_17_record3.wav\",\"1_11_17_record4.wav\",\"1_11_17_record5.wav\",\"1_11_17_record6.wav\",\"1_11_17_record7.wav\",\"1_11_17_record8.wav\",\"1_11_17_record9.wav\"]",

"recordFilePath": "http://地址/record//",

"unqualifiedReason": null,

"taskCreateTime": "2020-09-23 03:17:44",

"taskOngoingTime": null,

"taskCompleteTime": null

}, {

"taskId": 18,

"taskModelPath": null,

"userId": 1,

"word": "巴拉巴拉",

"taskStatus": 1,

"recordFileNameArray": "[\"1_14_26_record1.wav\",\"1_14_26_record2.wav\",\"1_14_26_record3.wav\",\"1_14_26_record4.wav\",\"1_14_26_record5.wav\",\"1_14_26_record6.wav\",\"1_14_26_record7.wav\",\"1_14_26_record8.wav\",\"1_14_26_record9.wav\"]",

"recordFilePath": "http://地址/record//",

"unqualifiedReason": null,

"taskCreateTime": "2020-09-23 06:26:33",

"taskOngoingTime": null,

"taskCompleteTime": null

}],

"total": 2

}

}

效果

b133fdaa90bc

image.png

需求

recordFileNameArray参数中返回可选择的录音名,recordFilePath参数中返回地址

在el-select中选择不同的录音名,点击播放按钮拼接地址和录音名,使用Audio播放录音

遇到问题

el-select的v-model为选中的内容,而列表中每一行都是不一样的,所以要在参数列表中新增元素用于指定该行选中的内容

then(response => {

let data = JSON.parse(JSON.stringify(response.data)).data

this.list = data.taskList

// 遍历列表,新增 audioName 参数指向当前选中的值

for (var i = 0; i < this.list.length; i++) {

this.list[i].audioName = this.getRecordList(this.list[i].recordFileNameArray)[0];

}

this.totalPage = data.total

})

v-for="(item) in getRecordList(scope.row.recordFileNameArray)"

:key="item"

:value="item">

播放

类似 el-select 等表单元素绑定了 类似 a.b 之类的属性,而不是直接的一级属性的话,当这个属性发生更改的时候,它的显示效果可能不会动态地进行更新,这个时候需要使用 Vue.$set 来进行更改 - https://www.cnblogs.com/wbyixx/p/12024643.html

v-for="(item) in getRecordList(scope.row.recordFileNameArray)"

:key="item"

:value="item">

播放

实现

html

v-for="(item) in getRecordList(scope.row.recordFileNameArray)"

:key="item"

:value="item">

播放

script

请求数据

getList () {

this.$axios.post(this.HOST + 'task/getAllTaskList', {

limit: this.listQuery.pageSize,

page: this.listQuery.pageNum

})

.then(response => {

let data = JSON.parse(JSON.stringify(response.data)).data

this.list = data.taskList

for (var i = 0; i < this.list.length; i++) {

this.list[i].audioName = this.getRecordList(this.list[i].recordFileNameArray)[0];

}

this.totalPage = data.total

}).catch(error => {

}).finally(() => {

this.listLoading = false

})

},

格式化recordFileNameArray参数

getRecordList (recordFileNameArray) {

return JSON.parse(recordFileNameArray)

},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值