当前位置:网站首页>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>
边栏推荐
- 从零开始配置 vim(10)——快捷键配置
- 快35了,还在“点点点”?那些入行几年的测试点工后来都怎么样了?
- 一个刚入行的测试员怎么样做好功能测试?测试思维真的很重要
- 兴业数金一面
- Little rookie Hebei Unicom induction training essay
- 2022.8.8 exam sweeps the horse (sweeper) antithesis
- 2022.8.8 Exam Travel Summary
- Chapter 21 Source Code File REST API Reference (3)
- [Kali Security Penetration Testing Practice Course] Chapter 7 Privilege Escalation
- js阻止事件冒泡方案
猜你喜欢
电子产品结构设计中的电磁兼容性(EMC)设计
MongoDB 常用查询语句
vue项目 npm run build 打包项目防止浏览器缓存
清洁环保的小型风电滑环基本介绍
Flink CDC 2.0及其他数据同步工具对比
实测办公场景下,国产远程控制软件的表现力如何?(技术解析)
Excel Advanced Drawing Skills 100 Lectures (23) - Countdown Counting in Excel
轻流CEO薄智元:从无代码到无边界
[Kali Security Penetration Testing Practice Tutorial] Chapter 6 Password Attack
推荐几款好用的MySQL开源客户端,建议收藏
随机推荐
exchange2010 邮件数据库无法装入
proxy代理服务
(面试加分新技能) 总结11个ES2022中你可能遗漏的语法
Example 043: Scope, class methods and variables
网页挖矿溯源?浏览器浏览历史查看工具Browsinghistoryview
uva1481
实例044:矩阵相加
【图像分类】2022-ConvMixer ICLR
单体架构应用和分布式架构应用的区别
【Image Classification】2022-ResMLP
所谓软件测试工作能力强,其实就是这 5 点
2022.8.9 Exam arrangement and transformation--1200 questions solution
WPF 实现更换主题色
盘式导电滑环的优点和缺点
成功执行数字化转型的9个因素
Excel Advanced Drawing Skills 100 Lectures (23) - Countdown Counting in Excel
清洁环保的小型风电滑环基本介绍
基础理解网络模型
新零售社交电商APP系统平台如何打造公域+私域流量?
如何快速成为一名软件测试工程师?测试员月薪15k需要什么技术?