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

编译运行报错:does not meet UI component syntax #4

Closed
peifeiyang opened this issue Nov 8, 2024 · 1 comment
Closed

编译运行报错:does not meet UI component syntax #4

peifeiyang opened this issue Nov 8, 2024 · 1 comment

Comments

@peifeiyang
Copy link

远程集成:
"@candies/image_cropper": "^1.0.2"
代码:

import * as image_cropper from "@candies/image_cropper";
import { image } from '@kit.ImageKit';

@Entry
@Component
struct Index {
  @State image: image.ImageSource | undefined = undefined;
  private controller: image_cropper.ImageCropperController = new image_cropper.ImageCropperController();
  @State config: image_cropper.ImageCropperConfig = new image_cropper.ImageCropperConfig(
    {
      maxScale: 8,
      cropRectPadding: image_cropper.geometry.EdgeInsets.all(20),
      controller: this.controller,
      initCropRectType: image_cropper.InitCropRectType.imageRect,
      cropAspectRatio: image_cropper.CropAspectRatios.custom,
    }
  );

  build() {
    Column() {
      if (this.image != undefined) {
        image_cropper.ImageCropper(
          {
            image: this.image,
            config: this.config,
          }
        )
      } else {
        Row()
          .height('100%')
          .width('100%')
      }
    }
  }
}

错误信息:
'image_cropper.ImageCropper(
{
image: this.image,
config: this.config,
}
)' does not meet UI component syntax.

@zmtzawqlp
Copy link
Contributor

经过研究,发现 ohpm install @candies/image_cropper 安装的包,不支持 import * as image_cropper from "@candies/image_cropper"; 这种写法,只能改成 import { ImageCropper } from "@candies/image_cropper";

即组件不支持这种引用方式,奇怪的是本地例子却支持

@zmtzawqlp zmtzawqlp pinned this issue Nov 8, 2024
@zmtzawqlp zmtzawqlp changed the title 编译报错:does not meet UI component syntax 编译运行报错:does not meet UI component syntax Nov 8, 2024
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

2 participants