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

推荐订阅源

N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
Docker
C
Cyber Attacks, Cyber Crime and Cyber Security
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Scott Helme
Scott Helme
A
About on SuperTechFans
WordPress大学
WordPress大学
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Schneier on Security

新城旧梦

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. 其他碰到的问题

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