当前位置:网站首页>ArkUI常见问题汇总【系列1】
ArkUI常见问题汇总【系列1】
2022-07-15 12:45:00 【大前端之旅】
今天我继续对社区里遇到的一些问题做一个整理
都是我回答过的一些问题,如果能真切的帮到开发者,那么很荣幸
问题1.ETS 的应用不能在P40模拟器上运行?
回答,P40模拟器是API 6,P40 PRO 才是API 7,然后P50是API8,所以你在使用模拟器的时候看一下你的项目用的是API的那个版本,寻找适合自己的。
问题2.数据存储SharePreference如何使用?
回答:
1.导入模块:import data_storage from ‘@ohos.data.storage’;
2.获取到要操作的Storage实例,用于进行数据存储操作 括号里面为应用程序内部数据存储路径。
static store = data_storage.getStorageSync(‘/data/data/’ + “string” );
3.存放数据
store .putSync(userId, value)
store.flushSync()
问题3.ets如何加载视频资源?

这种加载方式,无法在开发板上进行视频播放.


回答,你现在用的DevEco Studio 3.0.0.900,根本就没有rawfile资源文件夹,这个版本默认不常见,所以不能用这种引入方式,而是用$r(“app.media.viedeo.mp4”)
问题4.ETS支持chart组件吗?
回答:目前还不支持哦
问题5.请问ets怎么做的Http请求
ArkUI开发框架在 @ohos.net.http 模块提供了网络请求相关 API,
- 发起 http 网络请求需要申请 ohos.permission.INTERNET 权限。
- 发起 http 网络请求限定并发个数为 100 ,超过这一限制的后续请求会失败。
- 默认支持
https,如果要支持http,需要在config.json里增加network标签,属性标识 “cleartextTraffic”: true。
@ohos.net.http 模块定义的API注释的很清晰,首先调用 createHttp() 方法获取一个 HttpRequest 实例,然后调用 HttpRequest 的 request() 方法发送网络请求。
使用 @ohos.net.http 模块发起网络请求分为以下步骤:
1.引入http模块
import http from '@ohos.net.http';
2.创建一个httpRequest
let httpRequest = http.createHttp();
3.发起http请求
httpRequest 提供了两种 request() 方法进行网络请求,分别是无 RequestOptions 参数的请求和有 RequestOptions 参数的请求。
具体使用,可以看我的这篇文章:鸿蒙藏头诗应用
边栏推荐
- 浅谈 Slack Channel 支持的一些提高工作效率的特性
- Euler talk | developer community experience bureau starts at about 19:30 on July 14
- Where is the IBD file of MySQL in win11 virtual machine
- Is it true that double non undergraduate students cannot enter the big factory? Ali technology four sides + cross face +hr face, successfully got the offer!!
- 曾经,我对着AI客服喷了两分钟,它只回复了我的第一句话
- Data transmission: Practice of batch extraction of isomorphic and heterogeneous IP data sources
- Slow SQL analysis and optimization
- Evaluation of 5 internal systems to build a low code platform
- 是时候升级你的Junit了,Junit5超详细实战
- C# 使用ToolTip控件实现气泡提示
猜你喜欢

Award winning research | openeuler developer experience research questionnaire

C # use tooltip control to realize bubble prompt

The world's first commercial cryptographic chip against quantum attack | Muchuang

win11虚拟机里面mysql的ibd文件在哪里

Equal subtrees on binary trees

Use the kicad plug-in to visualize PCB welding

世界首款抗量子攻击商用密码芯片 | 沐创

LNMP architecture PHP installation

The latest research of Zhu Songchun's team: robots can "confide" with humans! Also said that the next step is to create "Ai white"

Talking about some features of improving work efficiency supported by slack channel
随机推荐
Event preview | Apache Doris x Apache seatunnel joint meetup to start registration!
Devsecops R & D security practice - Development
After 00, he graduated from Nanjing University and planned to be a special associate researcher. Netizens quarreled after picking out their papers
Chromium Threading and Task
普通二本毕业五年,备战两个月,四面阿里巴巴定级P7
论文学习(一)——MWP-BERT: Numeracy-Augmented Pre-training for Math WordProblem Solving
Thesis learning (I) -- MWP bert: numerical augmented pre training for math wordproblem solving
虚实之间03 | 有这些技术,你就是让数字人活起来的“神笔马良”
中国人力资源数字化生态图谱-灵活用工市场
在我旁边的同事突然晋升美团P7,却是只因偷偷学习了这份JVM笔记?
51nod 1413 power binary
Configure @ in vite to access files under Src
Which securities company should I choose to open an account in flush? Is it safe to open an account online?
DEVKIT-mpc5744p配置rtos
Serial port communication of esp32 (in the form of interruption and watchdog)
水电站设备也能远程运维
两年CRUD,普通二本毕业,挑战三个月面试阿里,成功拿下offer定级P7!年薪50w
想找个大券商开户?现在通过手机股票开户是安全的吗?
授人以渔-在 SAP MM 物料显示界面上看到一个字段,如何查找哪张数据库表的哪个字段进行的存储
中國人力資源數字化生態圖譜-靈活用工市場