uni-app schema2code 生成的admin界面缺少组件

uni-app schema2code 生成的admin界面缺少组件

产品分类:
uniCloud/App

示例代码:

<download-excel> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
<download-excel class="hide-on-phone" :fields="exportExcel.fields" :data="exportExcelData" :type="exportExcel.type" :name="exportExcel.filename">  
  <button class="uni-button" type="primary" size="mini">导出 Excel</button>  
</download-excel>

操作步骤:

schema2code 生成的admin界面

预期结果:

excel组件可用

实际结果:

excel组件未注册

bug描述:

list页面导出excel组件未注册


更多关于uni-app schema2code 生成的admin界面缺少组件的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

已解决 未使用admin模板

更多关于uni-app schema2code 生成的admin界面缺少组件的实战教程也可以访问 https://www.itying.com/category-93-b0.html


请升级admin版本,当前版本太低了

在 uni-app 的 admin 项目中,download-excel 组件需要手动注册。schema2code 生成的代码默认不包含此组件,因为它属于特定业务组件。

解决方案:

  1. 安装组件依赖:

    npm install vue-json-excel
    
  2. 在页面中注册组件:pages.json 对应的页面配置中,或直接在页面脚本中添加:

    import JsonExcel from 'vue-json-excel'
    
    export default {
      components: {
        'download-excel': JsonExcel
      },
      // ...其他代码
    }
    
  3. 全局注册(推荐):main.js 中全局注册,避免每个页面重复引入:

    import JsonExcel from 'vue-json-excel'
    Vue.component('download-excel', JsonExcel)
回到顶部