前端用插槽分析接收数组

前端el-dialog
插槽scope.row相当于当前行的数据对象
<template slot-scope="scope"> {{scope.row}} </template>

   <!-- 根据文件编号全局搜索-->
        <div class="globle_search">
            <a-input-search v-model="search_key" placeholder="请输入文件编号进行搜索" allowClear @search="search "  />
        </div>
        <el-dialog :visible.sync="visible" title="文件路径:">   
        //绑定数据
           <el-table border  :data="search_path"  >
	        <el-table-column type="index" label="序号" width="60"></el-table-column>
	        <el-table-column  label="文件路径" min-width="200" >
	        //插槽显示数组value
                <template  slot-scope="scope">
                    {{scope.row}}
                </template>
	        </el-table-column>
	      </el-table>
        </el-dialog>

js部分

  1. data
  data(){
        return {
            search_key:'',
            search_path:[],
            visible: false
        }
  1. 方法
 // 搜索事件
        search(e){
            if(!e){
                console.log("请输入关键字")
                return false;
                this.visible =false;
            }
            console.log(e);
            this.visible = true;

            let root=this;
            let url = "api/common/v1/get/file"
             root.$axios.$post(url, {
                "fileCode": e,
                }).then(res=>{
                    if(res.rv==200){
                    //接收后端数组
                        root.search_path = [];
                        root.search_path.push(...res.data.filePath);
                    }else{
                        root.search_path='';
                        root.$message.error(res.msg);
                    }
                })
                .catch(err => {
                    root.$message.info("暂无数据");
        });
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值