HarmonyOS 鸿蒙Next 仓颉运行后报错 the error occurs after the macro is expanded

HarmonyOS 鸿蒙Next 仓颉运行后报错 the error occurs after the macro is expanded

package ohos_app_cangjie_entry

internal import ohos.base.LengthProp
internal import ohos.component.Column
internal import ohos.component.Row
internal import ohos.component.Button
internal import ohos.component.Text
internal import ohos.component.CustomView
internal import ohos.component.CJEntry
internal import ohos.component.loadNativeView
internal import ohos.state_manage.SubscriberManager
internal import ohos.state_manage.ObservedProperty
internal import ohos.state_manage.LocalStorage
import ohos.state_macro_manage.Entry
import ohos.state_macro_manage.Component
import ohos.state_macro_manage.State
import ohos.state_macro_manage.r

import ohos.component.
import ohos.state_macro_manage.

import ohos.state_manage.*


@Entry //这里出现波浪线,提示:the error occurs after the macro is expanded
@Component
class MyView {
@State var clickWord = ‘点击我’
@State var dragCount = 0
func build() {
Row(12) {
Column{
Button(“请点击:${clickWord}”)
.onClick( {evt => clickWord = ‘被点击了’} )
Button(‘拖动次数:${ddragCount}’)
.onDragStart( {evt => this.dragCount += 1} )
}.width(100.percent)
}.height(100.percent)
}
}

以上新建[cangjie]empty ability后,输入代码后,上面的红色@Entry出现波浪线,提示the error occurs after the macro is expanded。

实在不知道,是什么原因导致的?


更多关于HarmonyOS 鸿蒙Next 仓颉运行后报错 the error occurs after the macro is expanded的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

在仓颉编程语言中,[@Entry](/user/Entry)是一个特殊的修饰符,用于指定一个函数或方法作为程序的入口点。然而,仓颉并不直接支持[@Entry](/user/Entry)修饰符。相反,仓颉通过其他方式指定程序的入口点,比如在main函数中调用其他函数作为程序的起点。

为了符合仓颉编程语言的最佳实践和标准流程,建议在编写仓颉代码时遵循其编程规范,并充分利用其提供的库和工具。如果需要了解更详细的编程规范、工具使用指南或库API概述,建议查阅仓颉编程语言开发文档以获取更多信息。

更多关于HarmonyOS 鸿蒙Next 仓颉运行后报错 the error occurs after the macro is expanded的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


仓颉开发鸿蒙应用的文档,哪里有呢?可以发个链接吗?

针对您提到的HarmonyOS 鸿蒙Next 仓颉运行后报错,错误信息指出错误发生在宏展开之后,这通常意味着在预处理阶段或编译初期出现了问题。可能的原因包括:

  1. 宏定义错误:检查您的宏定义是否正确,是否有未闭合的括号、错误的运算符或类型不匹配等问题。

  2. 编译器兼容性问题:确认您使用的编译器版本与HarmonyOS Next 仓颉要求的版本是否一致。不同版本的编译器可能在宏展开上有细微差异。

  3. 代码上下文问题:错误可能由宏展开后的代码上下文引起,如变量作用域、类型冲突等。检查宏展开后的代码是否合法。

  4. 头文件缺失或错误:确保所有必要的头文件都已正确包含,且没有重复包含或缺失的情况。

解决这类问题通常需要仔细检查代码和编译设置。您可以尝试简化宏定义,逐步排查问题源头。同时,确保开发环境配置正确,包括编译器设置、路径配置等。

如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html

回到顶部