美文网首页
记录一下问题

记录一下问题

作者: echo三文鱼 | 来源:发表于2018-09-28 17:15 被阅读0次

    1、table组件的列是循环出来的,其中有一个按钮时下载

          <template v-for="(action,index) in value.actions">
          <el-button  type="primary" plain v-if="action.text=='编辑'" @click="$emit(action.method,{row:scope.row,column:scope.column,index:scope.$index})">编辑</el-button>
          <el-button type="danger" plain v-if="action.text=='删除'" @click="$emit(action.method,{row:scope.row,column:scope.column,index:scope.$index})">删除</el-button>
          <a :href="url"  v-if="action.text=='下载'" @click="$emit(action.method,{row:scope.row,column:scope.column,index:scope.$index})">
            <el-button type="success" plain>下载</el-button>
          </a>
          <el-button  type="warning" plain v-if="action.text=='查看'" @click="$emit(action.method,{row:scope.row,column:scope.column,index:scope.$index})">查看</el-button>
          <i class="el-icon-zoom-in" title="查看详情" v-if="action.text=='放大镜'" @click="$emit(action.method,{row:scope.row,column:scope.column,index:scope.$index})"></i>
          <!-- <i class="detail" v-if="action.text=='查看'" @click="$emit(action.method,{row:scope.row,column:scope.column,index:scope.$index})">查看详情</i> -->
        </template>
    

    a标签的,在父页面

      <standard-table
                v-loading="loading"
                :layout="'prev, pager, next'"
                :columns="cla_columns"
                :pagination='pagination'
                :url="downloadUrl"
                :data="sourceData.slice((pagination.current_page-1)*pagination.page_size,pagination.current_page*pagination.page_size)"
                @current-change="current_change"
        @search="searchDetail"
        @download="downloadSource"
        @delete="deleteSource"
                
            ></standard-table>
    

    js部分

     // 下载素材
     downloadSource:function(row){
      this.downloadUrl=window.g.apiUrl+'/Materialapi/download?material_id='+row.row.material_id
      console.log(this.downloadUrl)
    },
    

    输出的地址是用网页打开是下载文件,但是执行的时候是刷新页面,查了一下,a标签的href和onclick事件同时存在时,先执行的是onclick事件,这里用到了组件,也许跟组件到页面渲染有关

    相关文章

      网友评论

          本文标题:记录一下问题

          本文链接:https://www.haomeiwen.com/subject/gsbpoftx.html