当前位置:网站首页>applet wxs
applet wxs
2022-08-10 03:59:00 【listen to me】
What is wxs
wxs (weixin script) is a set of scripting languages unique to the applet. Combined with wxml, the structure of the page can be constructed
Application scenarios of wxs
The function defined in the .js of the page cannot be called in wxml, however, the function in wxs can be called in wxml.Therefore, the typical application scenario of wxs in applet is "filter"
The relationship between wxs and JavaScript
- wxs has its own data type
- number, string, Boolean, Object, function, array, date, regexp
- wxs does not support syntax similar to ES6 and above
- Not supported: let, const, destructuring assignment, spread operator, arrow function, object property shorthand, etc.
- Support: var definition variable, common function function
- wxs follows CommonJS specification
- module object
- require() function
- module.exports object
Basic usage of wxs
1. Define an inline wxs script
wxs code can be written in tags in wxml files, just like JavaScript code can be written in html files
2. Define the wxs script for outreach
wxs code can also be written in files with a .wxs extension, just as JavaScript code can be written in files with a .js extension.Sample code:
// tools.wxs filefunction toLower(str){return str.toLowerCase();}module.exports = {toLower:toLower}Use of outbound scripts
When introducing an external wxs script in wxml, you must add module and src attributes to the tag, where:
- module is used to specify the name of the module
- src is used to specify the path of the script to be imported, and must be a relative path
Sample code:
view>{{m2.toLower(country)}}</view><wxs src="../../utils/tools.wxs" module="m2"></wxs>
边栏推荐
猜你喜欢

使用curl指令发起websocket请求
![[Red Team] ATT&CK - Self-starting - Self-starting mechanism using LSA authentication package](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[Red Team] ATT&CK - Self-starting - Self-starting mechanism using LSA authentication package

流星加速器木马分析与处置方案

实例047:函数交换变量

Anchor_generators.py analysis of MMDetection framework

The IDEA to automatically generate the serialVersionUID

实例043:作用域、类的方法与变量

The Evolutionary History of the "Double Gun" Trojan Horse Virus

vite基础,vite中 `@`符号是不被支持,不用@符号,直接用层级(./,../等)

单体架构应用和分布式架构应用的区别
随机推荐
2022.8.8 exam sweeps the horse (sweeper) antithesis
Excel Advanced Drawing Skills 100 Lectures (23) - Countdown Counting in Excel
HackTheBox——Beep
The IDEA to automatically generate the serialVersionUID
第二十一章 源代码文件 REST API 参考(三)
Example 044: Matrix Addition
vite基础,vite中 `@`符号是不被支持,不用@符号,直接用层级(./,../等)
Robust Real-time LiDAR-inertial Initialization(实时鲁棒的LiDAR惯性初始化)论文学习
C - The Battle of Chibi (dp加树状数组前缀和优化)
GDB command basic parameters
[Red Team] ATT&CK - Auto Start - Registry Run Key, Startup Folder
实例048:数字比大小
2022.8.8 Exam questions for photographer Lao Ma (photographer)
新零售社交电商APP系统平台如何打造公域+私域流量?
Flink CDC 2.0及其他数据同步工具对比
Kettle 裁剪表详解(truncate)
实例046:打破循环
盘式导电滑环的优点和缺点
MySQL: Introduction to Logging System | Error Log | Query Log | Binary Log: Bin-log Data Recovery Practice | Slow Log Query
The Evolutionary History of the "Double Gun" Trojan Horse Virus