当前位置:网站首页>Applets: WSX scripts
Applets: WSX scripts
2022-07-28 06:54:00 【Like Feynman%】
1.wxs Application scenarios of
wxml Unable to call .js Function of , But you can call wxs The function defined in . So in the applet wxs The typical application scenario is “ filter ”
2.wxs And JavaScript The relationship between 
3.wxs Basic grammar
3.1 inline :wxs The code can be written in wxml In the document <wxs> tag
wxml In the document <wxs></wxs> label , You must provide module attribute , Used to specify the current wxs Module name , Convenient in wxml Access the members in the module
// stay data Set in username attribute
<view>{
{m1.toUpper(username)}}</view>
<wxs module="m1">
module.exports.toUpper = function(str){
return str.toUpperCase()
}
</wxs>3.2 Outreach
And pages Folder under the same level utils establish tools.wxs file
<view>{
{m2.toLower(country)}}</view>
<wxs src="../../utils/tools.wxs" module="m2"></wxs>
//tools.wxs
function toLower(str){
return str.toLowerCase()
}
module.exports = {
toLower:toLower
}4.wxs characteristic
- stay wxs The function defined in , Cannot be used as an event callback function of a component
// Error model
<button bindtap='m2.toLower'> Button </button>- Isolation, ( The running environment and JavaScript Isolation ) wxs Cannot call js Defined function 、 You can't call what the applet provides API
- Good performance :ios equipment (wxs Faster than JavaScript2-20 times ), Android devices ( There is no difference between the two )
边栏推荐
- Which is the best air conduction Bluetooth headset? Air conduction Bluetooth headset ranking
- Ubuntu18.04搭建redis集群【学习笔记】
- Qgraphicsview promoted to qchartview
- Tcp/ip five layer model
- cocos2d-x 学习笔记——瓦片地图TiledMap
- It is recommended to wear air conduction earphones, which do not need to wear in ear
- 搭建PHP7私有仓库
- Analysis of reentrantlock source code of AQS
- Compilation and preprocessing of C language
- 遍历 二叉树
猜你喜欢
随机推荐
NAT和PAT的原理及配置
Question skimming record - hash table
Pku-2739-sum of constructive prime numbers
CentOS7部署MySQL数据库服务器
PKU-2739-Sum of Consecutive Prime Numbers(筛素数法打表)
Ubuntu18.04 set up redis cluster [learning notes]
Technology sharing | do you know the functions of the server interface automated testing and requests library?
Hdu-5805-nanoape loves sequence (thinking questions)
Which is the best one to make air conduction headphones? Inventory of the best air conduction headphones
Implementation of simple address book in [c language]
Life cycle (process) of software testing
Dynamic memory management function of C language
Analysis of cyclicbarrier source code of AQS
Qgraphicsview promoted to qchartview
ISO 3.0-server three power separation configuration
QT uses MSVC compiler to output Chinese garbled code
OSI七层模型
软件开发中常见模型
JS four operations are repackaged to solve the problem of precision loss
mongo ssl 配置实战









