Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to resolve component: VxeNumberInput,VxeUI.component干啥用的来着? #5782

Closed
lovelyJason opened this issue Mar 25, 2025 · 4 comments

Comments

@lovelyJason
Copy link

lovelyJason commented Mar 25, 2025

vben5: 5.4.2
vxe-table: ^4.7.93
vxe-pc-ui: ^4.2.26

同这个issue: #5478

在Grid的配置式写法中,

const gridOptions: VxeGridProps<RowType> = {
  border: true,
  editConfig: {
    trigger: 'click',
    mode: 'row',
  },
  columns: [
     {
       field: 'money',
       title: '金额',
       width: 180,
       editRender: { name: 'VxeNumberInput' },
     },

    { align: 'left', slots: { default: 'action' }, title: '操作' },
  ],
  keepSource: true,
  pagerConfig: {
    enabled: false,
    autoHidden: true,
  },
};

这种会报错

Failed to resolve component: VxeNumberInput
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.

我参考了官方文档的https://vxeui.com/o#/start/useImport
的vxe ui的三种导入方式

  1. 全局导入
  2. 按需导入
  3. 局部导入

其中1,2没什么好说的,局部导入是从vxe-pc-ui和vxe-table中导入组件,然后被vue app use使用
3的局部导入,文档有说明:

         // 注册组件
        // 如果页面中已经被显性导入了,则可以不用调用注册
        // 如果是配置式的,没有在页面中显性导入,则需要逐个注册
        VxeUI.component(VxeAlert)

但是实际上并没有效果好像。我使用vxe-table的原生标签直接使用editRender: { name: 'VxeNumberInput' },

这个是不是vxe table的一个bug或者说使用问题?谁有经验的,VxeUI.component函数是干啥用的来着?

Image

必须得使用vue的app.use才能支持在配置式写法中使用
editRender: { name: 'VxeNumberInput' }

@zuihou
Copy link

zuihou commented Mar 26, 2025

同问

@zynzszyn521
Copy link

别沉啊,应该怎么引用啊,vben的项目是vxe-table是项目的plugins,所以要在plugins里边使用app.use吗,否则在主项目里用app.use那是不是主项目也要install一下vxe-pc-ui包才行

@wLeeming
Copy link

wLeeming commented Apr 3, 2025

修改 ./packages/effects/plugins/src/vxe-table/index.ts

export * as VxeUIAll from 'vxe-pc-ui';

然后在 /apps/web-xxxx/src/bootstrap.ts 里面注册vxe-ui

全局安装

import { VxeUIAll } from '@vben/plugins/vxe-table';


async function bootstrap(namespace: string) {

  const app = createApp(App);
  app.use(VxeUIAll);
}

按需导入

import { VxeUIAll } from '@vben/plugins/vxe-table';


const setupVxeTable = (app: AppType) => {
  // 按需导入
  app.use(VxeUIAll.VxeAlert);
  app.use(VxeUIAll.VxeButton);
  .......
};

async function bootstrap(namespace: string) {
  const app = createApp(App);
  setupVxeTable(app);
}


@mynetfan
Copy link
Collaborator

mynetfan commented Apr 8, 2025

vxeUI的问题,目前需要将用到的组件全局注册才行。

@mynetfan mynetfan closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants