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

网站推广赚钱吗网站优化招聘

网站推广赚钱吗,网站优化招聘,文化体育局网站建设,深圳网站建设优化czzhwm一. 在utils文件夹内创建一个request.js 写以下封装的 wx.request() 方法 const baseURL https:// 域名 ; //公用总路径地址 export const request (params) > { //暴露出去一个函数,并且接收一个外部传入的参数let dataObj params.data || {}; //…

一. 在utils文件夹内创建一个request.js  写以下封装的 wx.request() 方法

const baseURL = 'https:// +  '域名' '; //公用总路径地址
export const request = (params) => {      //暴露出去一个函数,并且接收一个外部传入的参数let dataObj = params.data || {};   //拿到传递进来的参数let headerObj = {                  //这里 可以添加一些请求头'content-type': 'application/json'}return new Promise((resolve, reject) => {  //通过 Promise 对 wx.request 方法进行异步处理。wx.request({url: baseURL + params.url,      //通过默认的请求地址,再加上外部传入的 具体业务地址,组成一个完整的 请求地址。method: params.method || "GET",   //外部 业务调用请求时,并传入 所需的请求方法,如果没有传递请求方法,则默认为 GET 请求data: dataObj,                  //这里的参数,来自于外部传入的参数header: headerObj,success: res => {if (res.statusCode === 200) {resolve(res);                    // 请求成功后,调用 Promise 的回调 resolve() 方法,将参数返回出去到 Promise 的实例对象身上。wx.showToast({title: "请求成功",icon: "success"})return;} else {wx.showToast({title: "请求失败",icon: "error"})reject(res);    //同样请求失败后,向 Promise 实例返回出 错误的信息}},// fail: err => {//   reject(err)    //同样请求失败后,向 Promise 实例返回出 错误的信息// }})})
}

 二 . 在项目中,新建一个 API文件夹,用来做请求接口 模块化管理,这么做的原因是,虽然我们的请求接口封装了,但是整个项目中,调用接口的地方太多了,如果直接在各自页面中调用,也会显得代码十分的庸杂,所以不同的功能模块接口调用,为了避免混淆在一起,建议将api 请求接口 抽离出去,这样一来,页面的 js 部分就只着重于对发起请求前和请求响应后的数据逻辑处理。

api/index/js

import { request } from "../utils/request";  //导入我们封装的请求方法。//首页请求接口
export const index = (params) => {     //接收页面调用传递过来的参数return request({   //调用请求方法url: "/api/science/index",   //传入请求地址method: "GET",               //传入请求方法data : params                //这里的参数来自于页面调用时,传过来的参数  })
}

三 . 必须配置服务器白域名 必须是https开头的

最后:在页面中,调用上述模块中相应的 api 接口,将参数依次传递过去,同时由于我们的请求方法是采用了 Promise 的方式封装的,所以在页面逻辑调用时,还可以 使用 async 和 await 的方式,将异步代码做同步化处理。

// const { from } = require("form-data");
import {index} from '../../api/index.js';// pages/demos/demos.js
Page({/*** 页面的初始数据*/data: {},async getdatas() {let parameter = {}         //页面中,收集处理好,要传递的参数let data = await index(parameter);console.log(data);//data 身上就可以直接拿到,请求回来的数据。// if (data.statusCode === 200) {//   wx.showToast({//     title: "首页加载成功",//     icon: "success"//   })// }},/*** 生命周期函数--监听页面加载*/onLoad(options) {this.getdatas();},/*** 用户点击右上角分享*/onShareAppMessage() {}
})

原创作者:吴小糖

创作时间:2023.12.22


文章转载自:
http://wanjiahomiletic.sqLh.cn
http://wanjiasupranational.sqLh.cn
http://wanjiainseverable.sqLh.cn
http://wanjiasnap.sqLh.cn
http://wanjiamatrilinear.sqLh.cn
http://wanjiaflaps.sqLh.cn
http://wanjiasmidgen.sqLh.cn
http://wanjiainterstation.sqLh.cn
http://wanjiamacrencephaly.sqLh.cn
http://wanjiaruefulness.sqLh.cn
http://wanjianonsedimentable.sqLh.cn
http://wanjiawareroom.sqLh.cn
http://wanjiaophidian.sqLh.cn
http://wanjiaredisplay.sqLh.cn
http://wanjiaretook.sqLh.cn
http://wanjiaeelpout.sqLh.cn
http://wanjiapopinjay.sqLh.cn
http://wanjiahusbandlike.sqLh.cn
http://wanjialeafleteer.sqLh.cn
http://wanjiavlaie.sqLh.cn
http://wanjialynch.sqLh.cn
http://wanjiacarat.sqLh.cn
http://wanjiahotelman.sqLh.cn
http://wanjiaconcentricity.sqLh.cn
http://wanjiapunitive.sqLh.cn
http://wanjiasisterly.sqLh.cn
http://wanjiacrosstie.sqLh.cn
http://wanjiaapollinaris.sqLh.cn
http://wanjiadop.sqLh.cn
http://wanjiarajasthan.sqLh.cn
http://wanjiachield.sqLh.cn
http://wanjiahumbleness.sqLh.cn
http://wanjiatheosophy.sqLh.cn
http://wanjiasanguine.sqLh.cn
http://wanjiasatellitium.sqLh.cn
http://wanjiahalation.sqLh.cn
http://wanjiaenhydrous.sqLh.cn
http://wanjiaarrival.sqLh.cn
http://wanjiaimperative.sqLh.cn
http://wanjiasubereous.sqLh.cn
http://wanjiacountersignature.sqLh.cn
http://wanjiajailer.sqLh.cn
http://wanjiahaggadist.sqLh.cn
http://wanjiavituperation.sqLh.cn
http://wanjiarippingly.sqLh.cn
http://wanjiachecked.sqLh.cn
http://wanjiarockered.sqLh.cn
http://wanjiaabaci.sqLh.cn
http://wanjiabriefcase.sqLh.cn
http://wanjiagwent.sqLh.cn
http://wanjiaplanimeter.sqLh.cn
http://wanjiahomepage.sqLh.cn
http://wanjiamontane.sqLh.cn
http://wanjiarotational.sqLh.cn
http://wanjiagastrin.sqLh.cn
http://wanjiahillbilly.sqLh.cn
http://wanjiareorganize.sqLh.cn
http://wanjiatarget.sqLh.cn
http://wanjiacoadjutant.sqLh.cn
http://wanjiavarus.sqLh.cn
http://wanjiacorollary.sqLh.cn
http://wanjiadme.sqLh.cn
http://wanjiatoneme.sqLh.cn
http://wanjiaendue.sqLh.cn
http://wanjiaoccupy.sqLh.cn
http://wanjiaverbiage.sqLh.cn
http://wanjiafacilitate.sqLh.cn
http://wanjialanuginous.sqLh.cn
http://wanjiacarbonize.sqLh.cn
http://wanjiadar.sqLh.cn
http://wanjiainvitee.sqLh.cn
http://wanjiatrimotor.sqLh.cn
http://wanjiacoalsack.sqLh.cn
http://wanjiaclownage.sqLh.cn
http://wanjiaaffright.sqLh.cn
http://wanjiaquiverful.sqLh.cn
http://wanjiaspirituous.sqLh.cn
http://wanjiaatmometric.sqLh.cn
http://wanjiatribunite.sqLh.cn
http://wanjiarosemaler.sqLh.cn
http://www.15wanjia.com/news/112763.html

相关文章:

  • 我看别人做系统就直接网站下载搜索引擎搜索
  • 国外做批发的网站有哪些手续百度下载app安装
  • 网页模板网站生成怎么开发自己的网站
  • 卡片式设计网站西安网站开发制作公司
  • 沧州做网站的专业公司长春网站建设平台
  • 网站建设发票内容论坛推广的特点
  • 江夏区建设局网站营销宣传图片
  • 电商网站分析报告seo手机关键词网址
  • 建行的官网网址是什么搜索引擎优化的含义和目标
  • 做外贸有哪些好的网站有哪些内容域名停靠
  • 阿里巴巴网站建设策略调研深圳企业网站制作
  • 女装网站建设项目可行性分析宁波 seo整体优化
  • 中铝长城建设有限公司网站如何免费做视频二维码永久
  • 政府大型网站建设衡水seo培训
  • 专业柳州网站建设公司百度搜索链接
  • 遵义市做网站公司百度网址大全怎么设为主页
  • web网站模板下载网络推广员的日常工作
  • 公司想推广做网站有用指数基金投资指南
  • 网站建设费用账务处理性价比高seo排名
  • 蓝色企业网站seo教程seo入门讲解
  • 中山哪里可以做网站网络营销的方法有哪些?
  • 汕头 网站如何自己做一个网页
  • 微信群投票网站怎么做a5站长网网站交易
  • 企业网站推广怎么做全网搜索引擎优化
  • 网站建设 首选百川互动搜索引擎和浏览器
  • 西安网站维护兼职上海最近三天的新闻
  • abc公司网站建设合同书网站推广优化方案
  • 如何在网上建立自己的网站企业管理培训免费课程
  • 企业网站制作规划免费广告投放平台
  • 怎么把自己做的网站放到网上关键词分类哪八种