1、HarmonyOS的wukong 支持運行python腳本進行壓力或者常規測試嗎?
- Python腳本調用hdc命令,執行hdc shell wukong XXX
- wukong只支持穩定性壓測,普通測試建議使用arkxtest測試框架
2、Web組件頁面內跳轉時自定義WebHeader問題?
如果有比較多的業務是用的H5來實現,頁面加載時,在httpHeader中會包含一些信息,比如用戶信息,當前app主題信息等,HarmonyOS 上首次加載網頁的時候可以用loadUrl帶上header,但是在頁面再次跳轉時無法加上header信息,想問下這種場景有什么解決方案。目前嘗試過在onInterceptRequest攔截請求再用http去發送請求帶上header的方式,但是沒有效果
針對ArkTS中使用webview,設置webHeader。可參考鏈接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-webview-V5#geolocationpermissions
使用web的onInterceptRequest方法可以攔截
示例代碼:
import web_webview from ‘@ohos.web.webview’
@Entry
@Component
struct WebComponent {controller: web_webview.WebviewController = new web_webview.WebviewController()build() {Column() {Web({ src: $rawfile(‘i.html’), controller: this.controller }).onInterceptRequest((event) => {if (event) {console.log(‘urldddd:’ + event.request.getRequestUrl())}return null})}}
}
html:
<html>
<head><script src="https://xxx.com/vue/dist/vue.js"></script><script src="https://xxx.com/vue-router/dist/vue-router.js"></script></head><body><div id="app"><h1>Vue Router 示例</h1><ul><li><router-link to="/">首頁</router-link></li><li><router-link to="/about">關于</router-link></li></ul><router-view></router-view></div><script>// 定義兩個組件var Home = {template: '<div><h2>這是首頁</h2><p>歡迎來到我的網站</p></div>' };
var About = {template: '<div><h2>這是關于頁面</h2><p>Bing是一個智能的搜索引擎,可以幫你找到你想要的信息</p></div>' };
// 創建一個路由器實例
var router = new VueRouter({// 定義路由規則 routes:[{ path: '/', component: Home },{ path: '/about', component: About }]
});
// 創建和掛載根實例
var app = new Vue({el: '#app', router: router });
</script></body></html>
3、HarmonyOS 如何判斷系統nfc的開關狀態?
可以查詢當前NFC狀態,以及監聽NFC狀態變化,參考鏈接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-nfccontroller-V5#nfcstate
測試驗證controller.isNfcOpen()返回值正確的,demo如下:
import controller from '@ohos.nfc.controller'@Entry
@Component
struct TestNetConnectionPage {@State monitorNfcState: string = '';@State queryNfcState: string = '';@State isNfcOpen: boolean = false;aboutToAppear(): void {if (canIUse("SystemCapability.Communication.NFC.Core")) {controller.on("nfcStateChange", state => {this.monitorNfcState = state.toString();});}}build() {Row() {Column() {Row() {Text('監聽NFC狀態:').width('50%');Text(this.monitorNfcState).width('50%');}.alignSelf(ItemAlign.Start);if (canIUse("SystemCapability.Communication.NFC.Core")) {Row() {Button('查詢NFC狀態:').width('50%').onClick(() => {this.queryNfcState = controller.getNfcState().toString();});Text(this.queryNfcState).width('50%');}.alignSelf(ItemAlign.Start);}if (canIUse("SystemCapability.Communication.NFC.Core")) {Row() {Button('查詢NFC開關:').width('50%').onClick(() => {this.isNfcOpen = controller.isNfcOpen();});Text(this.isNfcOpen + '').width('50%');}.alignSelf(ItemAlign.Start);}}.width('100%')}.height('100%')}
}
4、HarmonyOS 關于定位能力,有沒有免費的kit提供?
關于定位,可以參照以下文檔:https://developer.huawei.com/consumer/cn/doc/HMSCore-Guides/harmonyos-location-develop-steps-0000001168458553
5、HarmonyOS 現在支持的rn第三方庫有哪些?
當前已支持的適配RN三方庫:https://github.com/orgs/react-native-oh-library/repositories?language=&sort=&type=all