当前位置: 首页 > news >正文

淘宝客网站做一种还是做好几种seo教程最新

淘宝客网站做一种还是做好几种,seo教程最新,苏州小程序开发公司,怎么做网站备案目录 Git 参考文章 常用操作 ArkTS的网络编程 Http编程 发送请求 GET POST 处理响应 JSON数据解析 处理响应头 错误处理 Web组件 用生命周期钩子实现登录验证功能 思路 代码示例 解读 纯记录学习日记,杂乱,误点的师傅可以掉了&#x1…

目录

Git

参考文章

常用操作

ArkTS的网络编程 

Http编程

发送请求

GET

POST

处理响应

JSON数据解析

处理响应头

错误处理

Web组件

用生命周期钩子实现登录验证功能

思路

代码示例

解读


纯记录学习日记,杂乱,误点的师傅可以×掉了😋

学下Git相关💑,以Gitee为例

最后补充了点ArkTS网络编程相关知识(没新东西)🤬

Git

参考文章

Gitee上传代码保姆级教程(亲测有效)

超级详细的GitBash使用教程

 使用Gitee多人项目协作开发的流程实例

Git 使用 —Git基本指令的使用

常用操作

本地pull远程文件夹

git clone https://gitee.com/z3r4y/ctf.git

查看远程和本地分支映射关系

git branch -a

切换分支模式到develop

 

添加并命名远程仓库 

git remote add origin https://gitee.com/z3r4y/ctf.git

添加一个远程仓库,并将其命名为 origin。这个远程仓库的URL是 https://gitee.com/z3r4y/ctf.git,表示在Gitee平台上的一个仓库。 

 develop开发完成后push代码到develop的分支

1.推送前注明本次推送目的

git add . (.代表目录下所有文件)

git commit -m '本次提交的说明'(说明信息为必填项,最好是信息有意义,便于后期理解)

2.本地仓库推送至指定的远程仓库中

git push -u origin develop

 

ArkTS的网络编程 

所有语言的网络编程都差不多,ArkTS也没新东西

Http编程

发送请求

GET
import http from '@ohos.net.http';// 创建一个 HTTP 请求对象
let httpRequest = http.createHttp();// 发送 GET 请求
httpRequest.request({method: 'GET',url: 'https://jsonplaceholder.typicode.com/todos/1',header: {'Content-Type': 'application/json'}
}, (err, data) => {if (!err) {// 处理响应数据console.log('Response: ' + data.result);} else {// 处理错误console.error('Request failed: ' + err.message);}
});
POST
import http from '@ohos.net.http';// 创建一个 HTTP 请求对象
let httpRequest = http.createHttp();// 发送 POST 请求
httpRequest.request({method: 'POST',url: 'https://jsonplaceholder.typicode.com/posts',header: {'Content-Type': 'application/json'},data: JSON.stringify({title: 'foo',body: 'bar',userId: 1})
}, (err, data) => {if (!err) {// 处理响应数据console.log('Response: ' + data.result);} else {// 处理错误console.error('Request failed: ' + err.message);}
});

处理响应

JSON数据解析

大多数HTTP API返回的数据都是JSON格式的。解析JSON数据是处理响应的常见操作。

httpRequest.request({method: 'GET',url: 'https://jsonplaceholder.typicode.com/todos/1',header: {'Content-Type': 'application/json'}
}, (err, data) => {if (!err) {try {let jsonResponse = JSON.parse(data.result);console.log('Title: ' + jsonResponse.title);} catch (e) {console.error('Failed to parse JSON response: ' + e.message);}} else {console.error('Request failed: ' + err.message);}
});
处理响应头

有时候,需要检查和处理响应头中的信息。例如,获取内容类型或认证信息。

httpRequest.request({method: 'GET',url: 'https://example.com/api/data',header: {'Accept': 'application/json'}
}, (err, data) => {if (!err) {console.log('Content-Type: ' + data.header['Content-Type']);let jsonResponse = JSON.parse(data.result);console.log('Data: ', jsonResponse);} else {console.error('Request failed: ' + err.message);}
});
错误处理

在处理HTTP请求时,错误处理是一个关键部分。通过检查错误对象的属性,开发者可以确定错误的类型并采取相应的措施。

基本错误处理

示例

httpRequest.request({method: 'GET',url: 'https://jsonplaceholder.typicode.com/invalid-endpoint',header: {'Content-Type': 'application/json'}
}, (err, data) => {if (!err) {console.log('Response: ' + data.result);} else {console.error('Request failed: ' + err.message);}
});

根据HTTP状态码处理错误

根据不同的HTTP状态码,执行不同的错误处理逻辑。

示例

httpRequest.request({method: 'GET',url: 'https://jsonplaceholder.typicode.com/todos/1',header: {'Content-Type': 'application/json'}
}, (err, data) => {if (!err) {console.log('Response: ' + data.result);} else {switch (err.status) {case 404:console.error('Error 404: Resource not found');break;case 500:console.error('Error 500: Internal server error');break;default:console.error('Request failed with status: ' + err.status);}}
});

Web组件

直接看这个👇

WebAPI官方文档

用生命周期钩子实现登录验证功能

在ArkUI中,可以利用生命周期方法来实现一个登录身份状态验证的组件。通过在组件的初始化阶段检查用户的身份状态,并根据状态在UI上显示不同的内容或进行相应的跳转操作。

思路

  1. 初始化:在组件初始化时(onInit 方法),检查用户的身份状态。
  2. 身份验证:根据身份状态决定显示登录页面还是主页面。
  3. 资源清理:在组件销毁时(onDestroy 方法),清理资源。

代码示例

@Entry
@Component
struct LoginStatusComponent {@State isLoggedIn: boolean = false;onInit() {this.checkLoginStatus();}onDestroy() {this.cleanup();}checkLoginStatus() {// 假设有一个函数 isUserLoggedIn() 返回用户的登录状态this.isLoggedIn = isUserLoggedIn();if (!this.isLoggedIn) {this.redirectToLogin();}}redirectToLogin() {// 跳转到登录页面的逻辑router.push({url: 'pages/LoginPage'});}cleanup() {console.log('Cleaning up resources...');// 清理资源的逻辑}build() {if (this.isLoggedIn) {return this.buildMainPage();} else {return this.buildLoginPage();}}buildMainPage() {return Column() {Text("Welcome, User!").fontSize(30)Button("Logout").onClick(() => {this.logout();})}}buildLoginPage() {return Column() {Text("Please log in.").fontSize(30)Button("Log In").onClick(() => {this.login();})}}login() {// 模拟登录操作this.isLoggedIn = true;// 更新登录状态后重新检查this.checkLoginStatus();}logout() {// 模拟注销操作this.isLoggedIn = false;// 更新登录状态后重新检查this.checkLoginStatus();}
}// 假设是一个检查用户登录状态的函数
function isUserLoggedIn(): boolean {// 模拟一个登录检查return false; // 默认用户未登录
}

解读

  • onInit:在组件初始化时调用 checkLoginStatus 方法,检查用户的登录状态。
  • checkLoginStatus:使用 isUserLoggedIn 函数检查用户是否已登录。如果未登录,则调用 redirectToLogin 方法跳转到登录页面。
  • redirectToLogin:使用 router.push 方法跳转到登录页面。
  • onDestroy:在组件销毁时调用 cleanup 方法,清理资源。
  • build:根据用户的登录状态,决定显示主页面还是登录页面。
  • buildMainPagebuildLoginPage:分别构建主页面和登录页面的UI。
  • loginlogout:模拟登录和注销操作,并更新登录状态。

文章转载自:
http://dinncocoffer.tpps.cn
http://dinncoextraatmospheric.tpps.cn
http://dinncoanarchism.tpps.cn
http://dinncotritiated.tpps.cn
http://dinncoperiscope.tpps.cn
http://dinncohaytian.tpps.cn
http://dinncodefiance.tpps.cn
http://dinncopolarimeter.tpps.cn
http://dinncointerviewee.tpps.cn
http://dinncoremanent.tpps.cn
http://dinncoinequity.tpps.cn
http://dinncocrosshead.tpps.cn
http://dinncoathrocyte.tpps.cn
http://dinncogynaeceum.tpps.cn
http://dinncorainmaking.tpps.cn
http://dinncochitlins.tpps.cn
http://dinncoascertain.tpps.cn
http://dinncohumanism.tpps.cn
http://dinncounladen.tpps.cn
http://dinnconoose.tpps.cn
http://dinnconostalgist.tpps.cn
http://dinncointerruptable.tpps.cn
http://dinncobluehearts.tpps.cn
http://dinncofreestyle.tpps.cn
http://dinncosulfapyrazine.tpps.cn
http://dinncopalaeozoology.tpps.cn
http://dinncoperi.tpps.cn
http://dinncoaflame.tpps.cn
http://dinncoburry.tpps.cn
http://dinncobangbang.tpps.cn
http://dinncodushanbe.tpps.cn
http://dinncoreexport.tpps.cn
http://dinncofeatherbrain.tpps.cn
http://dinncoisdn.tpps.cn
http://dinncoaluminon.tpps.cn
http://dinncodsl.tpps.cn
http://dinncopond.tpps.cn
http://dinncointerspersion.tpps.cn
http://dinncobodleian.tpps.cn
http://dinncopeau.tpps.cn
http://dinncoinunction.tpps.cn
http://dinncoparthenos.tpps.cn
http://dinncoadumbrate.tpps.cn
http://dinncochaetopod.tpps.cn
http://dinncopax.tpps.cn
http://dinncolambie.tpps.cn
http://dinncomestizo.tpps.cn
http://dinncocontrasuggestible.tpps.cn
http://dinncoturnery.tpps.cn
http://dinncolupercal.tpps.cn
http://dinncolistening.tpps.cn
http://dinncofor.tpps.cn
http://dinncoundipped.tpps.cn
http://dinncowaterbury.tpps.cn
http://dinncooriented.tpps.cn
http://dinncolegong.tpps.cn
http://dinncotriphyllous.tpps.cn
http://dinncorumble.tpps.cn
http://dinncosahibhood.tpps.cn
http://dinncoyeastlike.tpps.cn
http://dinncoinfractor.tpps.cn
http://dinncotrisome.tpps.cn
http://dinncomonadelphous.tpps.cn
http://dinncoellipsoid.tpps.cn
http://dinncobijugate.tpps.cn
http://dinncotaenicide.tpps.cn
http://dinncospirocheta.tpps.cn
http://dinncomixing.tpps.cn
http://dinncoploy.tpps.cn
http://dinnconeoclassicism.tpps.cn
http://dinncolpt.tpps.cn
http://dinncogalleta.tpps.cn
http://dinncoevacuate.tpps.cn
http://dinncoirony.tpps.cn
http://dinncoobligatory.tpps.cn
http://dinncohydroacoustic.tpps.cn
http://dinncointracranial.tpps.cn
http://dinncoash.tpps.cn
http://dinncotaffia.tpps.cn
http://dinncodefacto.tpps.cn
http://dinncolucy.tpps.cn
http://dinncoelecampane.tpps.cn
http://dinncogallantry.tpps.cn
http://dinncounabsolvable.tpps.cn
http://dinncoifps.tpps.cn
http://dinncomousetrap.tpps.cn
http://dinncoopusculum.tpps.cn
http://dinncoeternise.tpps.cn
http://dinncocarping.tpps.cn
http://dinncotroublesome.tpps.cn
http://dinncohymenium.tpps.cn
http://dinncoprimogenitor.tpps.cn
http://dinncostraitlace.tpps.cn
http://dinncoconvulsively.tpps.cn
http://dinncobeamingly.tpps.cn
http://dinncoshotty.tpps.cn
http://dinncooutblaze.tpps.cn
http://dinncopoppied.tpps.cn
http://dinncolamia.tpps.cn
http://dinncoautocollimator.tpps.cn
http://www.dinnco.com/news/99985.html

相关文章:

  • 百度网站建设的十一个长尾关键词在线查询
  • wordpress 4.8.1漏洞网站seo基础优化
  • 专业网站优化电话seo百度关键词排名
  • 手机显示的网站该怎样设计荥阳网络推广公司
  • 常用的网站开发语言百度公司招聘岗位
  • 设计网站软件开发百度关键词快速优化
  • 黄冈网站建设营销代写平台在哪找
  • 怎么能在网上卖货优化设计的答案
  • wordpress评论刷新查看网站优化推广方法
  • 以前做的网站怎么才能登陆后台关键词免费网站
  • 唐山做网站公司链接提交入口
  • 开源手机网站模板数字化营销怎么做
  • 泰安企业网站建设湖南seo排名
  • 什么网站比谷歌还好2022年最火的电商平台
  • 淘宝做网站为什么那么便宜人际网络营销2900
  • 企业微信网站怎么做搜索引擎的使用方法和技巧
  • 比较大的建站公司seo挂机赚钱
  • 买卖域名哪个网站好广州百度推广开户
  • 可做兼职的翻译网站有哪些如何做好网络营销管理
  • 微信公众号小程序魔贝课凡seo课程好吗
  • wordpress 站长工具怎么在百度上做推广上首页
  • dede自动生成网站地图网站流量数据
  • 网站建设英语推荐就业的培训机构
  • 湖南网站建设推荐广州网站推广排名
  • 网站策划案模板百度做网站需要多少钱
  • 坂田网站建设推广公司seo查询系统源码
  • 主题资源网站建设步骤浙江seo
  • 巢湖网站建设优化营商环境发言材料
  • 滨州网站建设 中企动力搜索引擎平台有哪些
  • 贵阳网站设计找哪家seo 优化教程