2 个回答

第一步:先定义组件,role-compontents.vue
<template>

<div>
    <!-- 常规选择 -->
    <Select placeholder="请输入职位名称!"
            filterable :not-found-text="'没有查询到相关人员!'"
            @on-change="saveUserAndOrganization">
        <Option v-for="option in roleList" :value="option.id" :key="option.id">
            {{option.text}}
        </Option>
    </Select>
</div>

</template>
<script></script>

第二步:在表格页面中引入定义好的的组件
import role from '@/views/business-components/bd-base-components/role-compontents.vue';

第三步:表格列数据中render

{

        key: '',
        title: '选择职位',
        align: 'center',
        render: (createElement, params) => {
          // role是引入的组件名称
          return createElement(role, {
            props: {
              dataType: 1,
              userId: params.row.userId
            }
          }, this.$slots.default);
        }
      },
新手上路,请多包涵

表头中的定义:

{
    title: '卷类型',
    key: 'volumeType',
    align: 'center',
    render: (h, params) => {
        return h('Select', {
            props:{
                value: this.data[params.index].value,
            },
            on: {
                'on-change':(event) => {
                    this.data[params.index].value= event;
                }
            },
        },
        this.options.map(function(option){
            return h('Option', {
                props: {value: option}
            }, option);
        })
        );
    },
},  

select对应data中的数据:

data: [{value: 这一行中对应的值}]

option参数对应options中的数据:

options: ['option1', 'option2']
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题