lowcode-engine
lowcode-engine copied to clipboard
使用脚手架制作antd-mobile物料,控制台一直报错:Cannot read properties of undefined (reading 'componentName')
使用脚手选择react-组件库,制作antd-mobile组件物料,导出了button
拖动button组件到设计面板时会报这两个这个错误:
1 . Uncaught TypeError: Cannot read properties of undefined (reading 'componentName')
2. Uncaught TypeError: Cannot read properties of undefined (reading 'node')
请看这个gif:

复现步骤:
- 使用脚手架选择react-组件库
- 安装 "antd-mobile": "^5.29.1", "antd-mobile-icons": "^0.3.0",
- 修改build.lowcode.js 代码如下:
const { library } = require('./build.json');
const { name, version } = require("./package.json");
module.exports = {
sourceMap: false,
alias: {
'@': './src',
lowcode: './lowcode'
},
plugins: [
[
'@alifd/build-plugin-lowcode',
{
noParse: true,
engineScope: '@alilc',
library,
npmInfo: {
package: name,
version,
},
lowcodeDir: 'lowcode',
entryPath: 'src/index.tsx',
categories: ['通用', '导航', '信息输入', '信息展示', '信息反馈'],
baseUrl: {
prod: `https://process.zafu.edu.cn/lowcode/components/${name}@${version}`,
daily: `https://alifd.alicdn.com/npm/${name}@${version}`,
},
builtinAssets: [
{
packages: [
{
package: 'moment',
version: '2.29.4',
urls: ['https://g.alicdn.com/mylib/moment/2.29.4/min/moment.min.js'],
library: 'moment',
},
{
package: 'lodash',
library: '_',
urls: ['https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js'],
},
{
package: 'iconfont-icons',
urls: '//at.alicdn.com/t/font_2369445_ukrtsovd92r.js',
},
{
package: 'antd-mobile-icons',
version: '0.3.0',
urls: [`https://unpkg.com/[email protected]/cjs/index.js`],
library: 'icons',
},
{
package: 'antd-mobile',
version: '5.29.1',
urls: [
`https://unpkg.com/[email protected]/umd/antd-mobile.js`,
],
library: 'antdMobile',
},
],
components: [],
},
],
},
],
],
};
- 在index.ts里只是单纯的导出Button
export { Button } from 'antd-mobile';
- 运行 yarn lowcode:dev
- 在lowcode目录中手动修改button.meta如下:
import { ComponentMetadata, Snippet } from '@alilc/lowcode-types';
const ButtonMeta: ComponentMetadata = {
componentName: 'Button',
title: '按钮',
category: '通用',
configure: {
props: [
{
title: '功能',
display: 'block',
type: 'group',
items: [
{
name: 'children',
title: {
label: '内容',
tip: 'children | 内容',
},
propType: {
type: 'oneOfType',
value: ['node', 'string'],
},
setter: ['SlotSetter', 'StringSetter', 'VariableSetter'],
},
{
name: 'type',
title: {
label: '原生类型',
tip: ' 设置 `button` 原生的 `type` 值',
},
propType: {
type: 'oneOf',
value: ['submit', 'reset', 'button'],
},
setter: [
{
componentName: 'RadioGroupSetter',
props: {
options: [
{
title: 'Submit',
value: 'submit',
},
{
title: 'Reset',
value: 'reset',
},
{
title: 'Button',
value: 'button',
},
],
},
},
'VariableSetter',
],
defaultValue: 'button',
},
{
name: 'href',
title: {
label: '跳转地址',
tip: 'href | 点击跳转的地址,指定此属性 button 的行为和 a 链接一致',
},
propType: 'string',
setter: ['StringSetter', 'VariableSetter'],
},
],
},
{
title: '外观',
display: 'block',
type: 'group',
items: [
{
name: 'color',
title: { label: '颜色', tip: 'color | 设置按钮颜色' },
propType: {
type: 'oneOf',
value: ['default', 'primary', 'success', 'warning', 'danger'],
},
setter: [
{
componentName: 'SelectSetter',
props: {
options: [
{
title: '主颜色',
value: 'primary',
},
{
title: '成功',
value: 'success',
},
{
title: '危险按钮',
value: 'danger',
},
{
title: '警告',
value: 'warning',
},
{
title: '默认',
value: 'default',
},
],
},
},
'VariableSetter',
],
},
{
name: 'fill',
title: { label: '填充模式', tip: 'fill | 设置按钮填充模式' },
propType: {
type: 'oneOf',
value: ['solid', 'outline', 'none'],
},
setter: [
{
componentName: 'SelectSetter',
props: {
options: [
{
title: '实体',
value: 'solid',
},
{
title: '线框',
value: 'outline',
},
{
title: '无填充',
value: 'none',
},
],
},
},
'VariableSetter',
],
},
{
name: 'size',
title: { label: '尺寸', tip: 'size | 设置按钮大小' },
propType: { type: 'oneOf', value: ['large', 'middle', 'small', 'mini'] },
setter: [
{
componentName: 'RadioGroupSetter',
props: {
options: [
{
title: '大',
value: 'large',
},
{
title: '中',
value: 'middle',
},
{
title: '小',
value: 'small',
},
{
title: '超小',
value: 'mini',
},
],
},
},
'VariableSetter',
],
defaultValue: 'middle',
},
{
name: 'shape',
title: {
label: '形状',
tip: 'shape | 设置按钮形状,可选值为 `rectangular`、 `rounded` 或者不设',
},
propType: { type: 'oneOf', value: ['default', 'rectangular', 'rounded'] },
defaultValue: 'default',
setter: [
{
componentName: 'RadioGroupSetter',
props: {
options: [
{
title: '默认',
value: 'default',
},
{
title: '矩形',
value: 'rectangular',
},
{
title: '圆角',
value: 'rounded',
},
],
},
},
'VariableSetter',
],
},
{
name: 'loadingIcon',
title: { label: '加载图标', tip: 'loadingIcon | 设置按钮的加载状态下图标组件' },
propType: 'node',
setter: {
componentName: 'SlotSetter',
// initialValue: {
// type: 'JSSlot',
// value: [
// {
// componentName: 'Icon',
// props: {
// type: 'DotLoading',
// color: 'currentColor',
// },
// },
// ],
// },
},
},
{
name: 'loadingText',
title: {
label: 'loadingText',
tip: 'loadingText | 加载状态下额外展示的文字',
},
propType: 'string',
setter: ['StringSetter', 'VariableSetter'],
},
{
name: 'block',
title: {
label: '自适应',
tip: 'block | 将按钮宽度调整为其父宽度的选项',
},
propType: 'bool',
setter: 'BoolSetter',
defaultValue: false,
},
// {
// name: 'danger',
// title: { label: '危险按钮', tip: 'danger | 设置危险按钮' },
// propType: 'bool',
// setter: 'BoolSetter',
// defaultValue: false,
// },
// {
// name: 'ghost',
// title: { label: '幽灵属性', tip: 'ghost | 幽灵属性,使按钮背景透明' },
// propType: 'bool',
// setter: 'BoolSetter',
// defaultValue: false,
// },
],
},
{
title: '状态',
display: 'block',
type: 'group',
items: [
{
name: 'loading',
title: { label: '载入状态', tip: 'loading | 设置按钮载入状态' },
propType: 'bool',
setter: ['BoolSetter', 'VariableSetter'],
},
{
name: 'loading',
title: {
label: '载入状态',
tip: ' boolean | auto ,设置按钮载入状态',
},
propType: {
type: 'oneOf',
value: ['auto', false, true],
},
setter: [
{
componentName: 'RadioGroupSetter',
props: {
options: [
{
title: 'auto',
value: 'auto',
},
{
title: 'false',
value: false,
},
{
title: 'true',
value: true,
},
],
},
},
'VariableSetter',
],
defaultValue: false,
},
{
name: 'disabled',
title: { label: '是否禁用', tip: 'disabled | 是否为禁用状态' },
propType: 'bool',
setter: ['BoolSetter', 'VariableSetter'],
defaultValue: false,
},
],
},
{
name: 'onClick',
title: { label: '点击回调', tip: '点击按钮时的回调' },
propType: 'func',
},
],
supports: {
style: true,
events: [
{
name: 'onClick',
template:
"onClick(event,${extParams}){\n// 点击按钮时的回调\nconsole.log('onClick', event);}",
},
],
},
component: {},
},
};
const snippets: Snippet[] = [
[
{
title: '主按钮',
screenshot: require('./__screenshots__/button-1.png'),
schema: {
componentName: 'Button',
props: {
color: 'primary',
children: '主按钮',
},
},
},
{
title: '次按钮',
screenshot: require('./__screenshots__/button-2.png'),
schema: {
componentName: 'Button',
props: {
color: 'default',
children: '次按钮',
},
},
},
{
title: '危险按钮',
screenshot: require('./__screenshots__/button-3.png'),
schema: {
componentName: 'Button',
props: {
color: 'danger',
children: '危险按钮',
},
},
},
{
title: '警告按钮',
screenshot: require('./__screenshots__/button-3.png'),
schema: {
componentName: 'Button',
props: {
color: 'warning',
children: '警告按钮',
},
},
},
{
title: '成功按钮',
screenshot: require('./__screenshots__/button-3.png'),
schema: {
componentName: 'Button',
props: {
color: 'success',
children: '成功按钮',
},
},
},
{
title: '文字按钮',
screenshot: require('./__screenshots__/button-4.png'),
schema: {
componentName: 'Button',
props: {
fill: 'none',
children: '文字按钮',
},
},
},
],
];
export default {
...ButtonMeta,
snippets,
};
BUG截图:

- AliLowCodeEngine version: [v1.0.18]
- AliLowCodeEngineExt version: [ v1.0.5]
- chrome version: [ 112.0.5615.121]
- "antd-mobile": "^5.29.1", "antd-mobile-icons": "^0.3.0",
我想请问这个是什么东西引起的哇? 我该从哪里找问题? 我该找那块文档?
请提供可以用来复现的代码包
请提供可以用来复现的代码包
...我发现我的问题了,我写的snippets,没有生效,多了层括号
...我发现我的问题了,我写的snippets,没有生效,多了层[]括号