惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
Jina AI
Jina AI
雷峰网
雷峰网
月光博客
月光博客
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
B
Blog RSS Feed
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
Security Latest
Security Latest
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
A
Arctic Wolf
Latest news
Latest news
Attack and Defense Labs
Attack and Defense Labs
I
Intezer
F
Fortinet All Blogs
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
Help Net Security
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 【当耐特】
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
H
Help Net Security
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tenable Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog

新城旧梦

Anaconda环境下安装PYG及CUDA - 新城旧梦 高中三年复盘 - 新城旧梦 2024年终总结 - 新城旧梦 高数上笔记 - 新城旧梦 git仓库迁移并保留所有记录 - 新城旧梦 记一次ssh无法登陆的处理 - 新城旧梦 amftp 3.0 for docker 发布 - 新城旧梦 Amysql 1.7 for Docker发布 - 新城旧梦 2023新年快乐 - 新城旧梦
鸿蒙开发记录 - 新城旧梦
dadafox · 2024-12-01 · via 新城旧梦

1. 云对象使用

cke_142.png

按照文档给出代码,直接使用会报错,原因为res没有给定类型,鸿蒙要求所有变量必须指定类型,例如:

interface Obj {
result: number
}

let myCloudObject = importObject(MyCloudObject);
myCloudObject.add(1, 2).then((addResult: Obj) => {
console.log(`1 + 2 = ${addResult.result}`);
});

(PS:serverless服务不支持模拟器调试,所以如果没有真机的建议不要使用了)

2. 显示当前日期时间

文档的代码模拟器运行有些问题,可参考:

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';
  @State time: string = '';

  aboutToAppear(): void {
    let date = new Date();
    let year = date.getFullYear();
    let month = date.getMonth() + 1;
    let day = date.getDay(); 
    let hour = date.getHours();
    let mins = date.getMinutes();
    let seconds = date.getSeconds();
    this.time = `${year}-${month}-${day} ${hour}:${mins}:${seconds}`;
  }

  build() {
    RelativeContainer() {
      Text(this.time)
        .id('HelloWorld')
        .fontWeight(FontWeight.Bold)
        .alignRules({
          center: { anchor: '__container__', align: VerticalAlign.Center },
          middle: { anchor: '__container__', align: HorizontalAlign.Center }
        });
    }
    .height('100%')
    .width('100%');
  }
}

3. 其他碰到的问题

官方的软件包加密可能会导致软件异常,本地配置的软件包加密如果使用记得配置白名单,特别是一些写死的变量,否则软件会异常