赞
踩
定义了一个类,直接在类名前添加export default
,导入使用时类名不需要放在大括号内
export default class Constants {
static readonly MATCH_PARENT = '100%'
}
// 导入使用
import Constants from ‘./Constants’ //路径根据文件位置进行处理
TextInput({ placeholder: $r('app.string.username'), text: "11111" })
.width(Constants.MATCH_PARENT)
直接定义类,然后使用export default new +类进行到处,导入使用时类名不需要放在大括号内
class LogUtils { private domain: number = 0xFF00 private format: string = '%{public}s, %{public}s' private tag:string="Harmony" debug(...args: any[]): void { hilog.debug(this.domain, this.tag, this.format, args) } info(...args: any[]): void { hilog.debug(this.domain, this.tag, this.format, args) } } export default new LogUtils() // 导
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。