我正在尝试使用https://react-table.js.org/#/story/readme在vue.js应用中集成https://github.com/akxcv/vuera。
我的main.js:
import Vue from 'vue'
import { VuePlugin } from 'vuera'
import App from './App'
import router from './router'
Vue.config.productionTip = false
Vue.use(VuePlugin)
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App },
})
我的HelloWorld.vue:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<ReactTable :data="data" :columns="columns" />
</div>
</template>
<script>
import ReactTable from 'react-table'
import 'react-table/react-table.css'
export default {
name: 'HelloWorld',
components: { ReactTable },
data () {
return {
msg: 'Welcome to Your Vue.js App',
columns: [{ Header: 'Name', accessor: 'name' }],
data: [ {name: 'tom'}]
}
}
}
</script>
运行此代码后,我在控制台中收到两个错误:
[Vue warn]: Error in mounted hook: "TypeError: children is not a function"
found in
---> <ReactWrapper>
<ReactTable>
<HelloWorld> at src/components/HelloWorld.vue
<App> at src/App.vue
<Root>
和:
vue.esm.js?efeb:1717 TypeError: children is not a function
at ReactTable.render (index.js?5f89:822)
at eval (ReactCompositeComponent.js?063f:793)
at measureLifeCyclePerf (ReactCompositeComponent.js?063f:73)
at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js?063f:792)
at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js?063f:819)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js?063f:359)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js?063f:255)
at Object.mountComponent (ReactReconciler.js?c56c:43)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js?063f:368)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js?063f:255)
这是错误的我编码或vuera插件只是没有正确处理ReactTable组件集成?
非常感谢任何想法!
答案 0 :(得分:3)
所以我重新创建了项目并且它对我来说很好,下面是我使用的依赖项集。我认为你的情况可能只是版本不匹配问题
case
请确保您尝试使用以上版本。输出是
如果您想要克隆和测试
,该项目可在以下链接中找到