小小白每天不奋斗 2022-10-14 15:12 采纳率: 80%
浏览 95
已结题

vue3引入组件报错

子组件:


```bash
<template>
  <div>
    <a-table :columns="columns" :data-source="data1"></a-table>
  </div>
</template>
<script>
import { defineComponent } from 'vue'
export default defineComponent({
  props:{
     data1: Array,
     columns: Array
  },
  setup(props,context){
     const p = toRefs(props);
     const data1 = p.data1;
     const columns = p.columns;
     console.log(data1)
     return{
      data1,
      columns
     }
  }
})
</script>


父组件:

```bash
<template>
  <stable :data1="data"  :columns="columns"></stable>
</template>

<script>
import { reactive, onMounted  } from 'vue'
import { stable } from '@/components/Table/index.vue'
import { getList } from '@/api/news'

export default {
  components: { stable },
  setup() {
   let data  = reactive([])
   let columns = reactive([
  {
    dataIndex: 'title',
    key: 'title',
    slots: {
      title: '标题',
      customRender: 'title',
    },
  },
  {
    title: '发布人',
    dataIndex: 'fbr',
    key: 'fbr',
  },
  {
    title: '关键字',
    dataIndex: 'keywords',
    key: 'keywords',
  },
  {
    title: '来源',
    key: 'source',
    dataIndex: 'source',
    slots: {
      customRender: 'source',
    },
  },
  {
    title: 'Action',
    
    slots: {
      customRender: 'action',
    },
  },
])
  onMounted(
      getList().then(res=>{
        debugger
        if(res && res.code === 10000){
           data = res.data.rows
        }
      })
    )
    return {
      data,
      columns
    }
  },
}
</script>

报错:The requested module '/src/components/Table/index.vue?t=1665730501281' does not provide an export named 'stable' (at index.vue:7:10)

  • 写回答

3条回答 默认 最新

  • weixin_45840746 2022-10-14 16:00
    关注

    import Stable from "xxxx";

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 11月29日
  • 已采纳回答 11月21日
  • 创建了问题 10月14日