Vue实现详细界面里面有一个列表

目录

Vue实现详细界面里面有一个列表

理一下思路:

效果如下:

[1、 主页面正常写](#1、 主页面正常写)

2、详细界面(重点)

3、详细界面里面的列表(重点)

要点:


Vue实现详细界面里面有一个列表

理一下思路:

1、首先需要这条数据的主键id,用它来获得详细界面所需的值,

2、在详细界面中通过父子组件的关系传递这个id,使得自己写的列表组件可以获得这个id值去查数据。

效果如下:

1、 主页面正常写

css 复制代码
<span @click="addOrUpdateHandle(scope.row.id,true)">详情</span>

addOrUpdateHandle(id, isDetail) {
this.formVisible = true
this.$nextTick(() => {
this.$refs.xxxxx.init(id, isDetail)
})

},

2、详细界面(重点)

:pid="dataForm.id"

css 复制代码
  <el-col :span="24"">
              <template>
                <el-tabs >
                  <div class="">信息</div>
                  <recordForm :pid="dataForm.id" :cylx="0" :isCheck="!!isDetail" style="height: 500px"></recordForm>
                </el-tabs>
              </template>
            </el-col>

PS:记得导入你自己写的组件

3、详细界面里面的列表(重点)

注意关注 pid

css 复制代码
created() {
    if (!(this.pid == '' || this.pid == undefined)) {
      this.finitData(this.pid)
    }

  },
css 复制代码
 methods: {
    finitData(v_id, flag) {
      this.query.xxxId = v_id
      this.listLoading = true
      let query = {
        ...this.listQuery,
        ...this.query
      }
      request({
        url: ``, 
        method: 'get',
        data: query
      }).then(res => {
        this.list = res.data.list
        this.total = res.data.pagination.total
        this.listLoading = false
        this.$nextTick(() => {
          this.tableHeight = '100%'
        })
      })
    },
}

要点:

就是 父子传id,这里面个人感觉像是 爷传父、父传子

相关推荐
陈随易29 分钟前
专注飞机 FocusFlight,两个人把番茄钟做成了一趟航班
前端·后端·程序员
总要学点什么1 小时前
第98篇:三维特效-材质线效果——给一条线换十种材质,虚线的图案只填了一半
开发语言·前端·javascript·ecmascript·gis·webgl·材质
10share1 小时前
基于大模型的 i18n 方案:把中文原文当 Key,轻松搞定多语言维护
前端·vue.js
OpsEye2 小时前
混合云 AI 架构,如何统一做敏感内容拦截?
javascript·ai编程
Funlang3 小时前
给机器写的 JavaScript 造个笼子
开发语言·javascript·ecmascript
古茗前端团队4 小时前
由 key 引发的思考
前端·javascript·react.js
kyriewen4 小时前
我扫了 422 个仓库,近一半 CI 在裸装依赖
前端·javascript·程序员
鹏多多4 小时前
AI 到底能不能独立做个产品?我拿一个小程序验证了
前端·微信小程序·ai编程
火山引擎开发者社区4 小时前
构建专属的飞书群开发助手,AgentKit Studio 一键部署 DeepSeek Harness Super-Agent
前端
啾咪orJIUMI6 小时前
Vue 3 + 高德地图封装实战:点位、区域、Loca 流光与 Vue 信息窗体
前端·vue.js