当前位置:网站首页>【微信小程序】小程序的宿主环境
【微信小程序】小程序的宿主环境
2022-06-30 15:48:00 【苏凉.py】
作者简介:苏凉(专注于网络爬虫,数据分析,正在学习前端的路上)
博客主页:苏凉.py的博客
系列专栏:小程序开发基础教程
名言警句:海阔凭鱼跃,天高任鸟飞。
要是觉得博主文章写的不错的话,还望大家三连支持一下呀!!!
关注点赞收藏
每日推荐
给大家推荐一款神器。无论你是学生党还是上班族都可以使用,这里涵盖了面试题库,在线刷题,各个大厂的面试/笔试真题等。如果你还是学生,最重要的一点就是模拟面试功能,智能AI1v1面试,帮助你早日拿到大厂offer!点击链接即可直达!=>牛客网-找工作神器
宿主环境
一、什么是宿主环境?
宿主环境( host environment)指的是程序运行所必须的依赖环境。
例如:Android系统和iOS系统是两个不同的宿主环境。安卓版的微信App是不能在 iOS环境下运行的,所以,Android是安卓软件的宿主环境,脱离了宿主环境的软件是没有任何意义的!
二、小程序的宿主环境
在手机上,小程序的宿主环境就是我们的手机微信,通常小程序可以通过借助宿主环境提供的能力,可以完成许多普通网页无法完成的功能:微信支付,微信扫码,微信登录以及定位等等。
三、小程序宿主环境包含的内容
1.通信模型
通信的主体
小程序中通信的主体是渲染层和逻辑层,其中:
- WXML模板和WXSS样式工作在渲染层
- JS脚本工作在逻辑层

小程序的通信模型
小程序中的通信模型分为两部分(都由微信客户端进行转发)
渲染层和逻辑层之间的通信

逻辑层和第三方服务器之间的通信

2.运行机制
小程序启动的过程
- 把小程序的代码包下载到本地
- 解析app.json全局配置文件
- 执行app.js小程序入口文件,调用App()创建小程序实例
- 渲染小程序首页
- 小程序启动完成
小程序页面渲染过程
- 加载解析页面的.json配置文件
- 加载页面的.wxml模板和.wxss样式
- 执行页面的.js 文件,调用Page()创建页面实例
- 页面渲染完成
3.组件
小程序中的组件也是由宿主环境提供的,开发者可以基于组件快速搭建出漂亮的页面结构。官方把小程序的组件分为了9大类,分别是:
- 视图容器
- 基础内容
- 表单组件
- 导航组件
- 媒体组件
- map地图组件
- canvas画布组件
- 开放能力
- 无障碍访问
4.API
小程序官方把API分为了如下3大类:
事件监听API
特点:以on开头,用来监听某些事件的触发
举例:wx.onWindowResize(function callback)监听窗口尺寸变化的事件同步API
特点1:以Sync结尾的API都是同步API
特点2:同步API的执行结果,可以通过函数返回值直接获取,如果执行出错会抛出异常举例:wx.setStorageSync("'key" , 'value')向本地存储中写入内容异步API
特点:类似于jQuery 中的$.ajax(options)函数,需要通过success、fail、complete接收调用的结果举例:wx.request()发起网络数据请求,通过success回调函数接收数据
更多题库和知识点总结,面试技巧请看=>牛客网,快来和我一起刷题吧!
边栏推荐
- Mathematical modeling for war preparation 35 time series prediction model
- Niuke network: longest continuous subarray with positive product
- What is XR extended reality and what are the XR cloud streaming platforms
- 备战数学建模35-时间序列预测模型
- 新茶饮“死去活来”,供应商却“盆满钵满”?
- How to connect the Internet Reading Notes - Summary
- [Verilog basics] octal and hexadecimal representation of decimal negative numbers
- 2022 Blue Bridge Cup group B -2022- (01 backpack to calculate the number of schemes)
- CloudXR如何推动XR的未来发展
- POJ Project Summer
猜你喜欢

Mathematical modeling for war preparation 33- grey prediction model 2

抖快B为啥做不好综艺

Compulsory national standard for electronic cigarette GB 41700-2022 issued and implemented on October 1, 2022

Installing jupyter notebook under Anaconda

Which direction should college students choose to find jobs after graduation?

Half year inventory of new consumption in 2022: the industry is cold, but these nine tracks still attract gold

RT-Thread 堆區大小設置

Under the pressure of technology, you can quickly get started with eth smart contract development, which will take you into the ETH world

数据挖掘知识点整理(期末复习版)
![[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection](/img/c2/d6760826b81589781574aebff61f9a.png)
[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection
随机推荐
实时渲染和预渲染有什么区别
MicroBlaze serial port learning · 2
搬运两个负载均衡的笔记,日后省的找
360 digital, ant group, etc. were selected as member units of the "business security promotion plan" of the Chinese Academy of Communications
microblaze 串口学习·2
Asp. NETCORE uses cache and AOP to prevent repeated commit
几百行代码实现一个 JSON 解析器
附加:(还没写,别看~~~)CorsFilter过滤器;
备战数学建模33-灰色预测模型2
register_chrdev和cdev_init cdev_add用法区别
牛客网:乘积为正数的最长连续子数组
15年做糊21款硬件,谷歌到底栽在哪儿?
19:00 p.m. tonight, knowledge empowerment phase 2 live broadcast - control panel interface design of openharmony smart home project
CVPR 2022 - Tesla AI proposed: generalized pedestrian re recognition based on graph sampling depth metric learning
Mysql8.0 method and steps for enabling remote connection permission
【机器学习】K-means聚类分析
RT thread heap size Setting
MySQL8.0开启远程连接权限的方法步骤
Log4j2 advanced use
What is the difference between real-time rendering and pre rendering
