"info< span style="color: #800000;">">
var str = 'Xiao Ming';
var fun = function (a,b){
return a + b
}
module.exports={
str: str,
fun:fun
}
{{info.str}} {{info.fun(11,44)} }
// Required, only ES5 syntax can be used;
var str = 'Xiao Ming'
var fun = function (a, b) {
return a + b
}
module.exports = {
// This cannot be abbreviated here;
str:str,
fun:fun
}
Introduced wxml page
// Absolute path cannot be used here, only the first path
// Can only be played layer by layer; span>"./wxs.wxs" module="info< span style="color: #800000;">"/>
{{info.str}} {{info.fun(12,33)} }
data: {
num :22.232341
},
Define wxs method
function floats(change,number){
// Determine whether there are parameters to pass, and if there are any parameters, use his or not Just use 2
var number = number || 2;
// If you pass a string, convert it to a number span>
var f_change = fparseFloat(change)
return f_change.toFixed(number)
}
module.exports = {
floats: floats
}
Use wxml
"./wxs.wxs" module="info" / > {{info.floats(num)}}
You can follow my WeChat public “front-end pseudo-uncle”
>
wxs weixin script, script language for small programs; can be combined with wxml to build page structure;
To put it plainly, it is the place to write function expressions in the applet;
wxs is used directly in wxml, refresh again if there is an error It can be solved
"info">
var str = 'Xiao Ming';
var fun = function (a,b){
return a + b
}
module.exports={
str: str,
fun:fun
}
{{info.str}} {{info.fun(11,44)} }
// Required, only ES5 syntax can be used;
var str = 'Xiao Ming'
var fun = function (a, b) {
return a + b
}
module.exports = {
// This cannot be abbreviated here;
str:str,
fun:fun
}
Introduced wxml page
// Absolute path cannot be used here, only the first path
// Can only be played layer by layer; span>"./wxs.wxs" module="info< span style="color: #800000;">"/>
{{info.str}} {{info.fun(12,33)} }
data: {
num :22.232341
},
Define wxs method
function floats(change,number){
// Determine whether there are parameters to pass, and if there are any parameters, use his or not Just use 2
var number = number || 2;
// If you pass a string, convert it to a number span>
var f_change = fparseFloat(change)
return f_change.toFixed(number)
}
module.exports = {
floats: floats
}
Use wxml
"./wxs.wxs" module="info" / > {{info.floats(num)}}
You can follow my WeChat public “front-end pseudo-uncle”
>
"info< /span>">
var str = 'Xiao Ming';
var fun = function (a,b){
return a + b
}
module.exports={
str: str,
fun:fun
}
{{info.str}} {{info.fun(11,44)} }
External introduction of wxs syntax
wxs.wxs
// Required, only ES5 syntax can be used;
var str = 'Xiao Ming'
var fun = function (a, b) {
return a + b
}
module.exports = {
// This cannot be abbreviated here;
str:str,
fun:fun
}
Introduced wxml page
// Absolute path cannot be used here, only the first path
// Can only be played layer by layer; span>"./wxs.wxs" module="info< span style="color: #800000;">"/>
{{info.str}} {{info.fun(12,33)} }
data: {
num :22.232341
},
Define wxs method
function floats(change,number){
// Determine whether there are parameters to pass, and if there are any parameters, use his or not Just use 2
var number = number || 2;
// If you pass a string, convert it to a number span>
var f_change = fparseFloat(change)
return f_change.toFixed(number)
}
module.exports = {
floats: floats
}
Use wxml
"./wxs.wxs" module="info" / > {{info.floats(num)}}
You can follow my WeChat public “front-end pseudo-uncle”
>
// Required, only ES5 syntax can be used;< /span>
var str = 'Xiao Ming'
var fun = function (a, b) {
return a + b
}
module.exports = {
// This cannot be abbreviated here;
str:str,
fun:fun
}
// Absolute path cannot be used here, only the first path
// Can only be played layer by layer; span>"./wxs.wxs" module="info< span style="color: #800000;">"/>
{{info.str}} {{info.fun(12,33)} }
Use scenario
Define variables
data: {
num :22.232341
},
Define wxs method
function floats(change,number){
// Determine whether there are parameters to pass, and if there are any parameters, use his or not Just use 2
var number = number || 2;
// If you pass a string, convert it to a number span>
var f_change = fparseFloat(change)
return f_change.toFixed(number)
}
module.exports = {
floats: floats
}
Use wxml
"./wxs.wxs" module="info" / > {{info.floats(num)}}
You can follow my WeChat public “front-end pseudo-uncle”
>
data: {
num :22.232341
},
function floats(change,number){
// Determine whether there are parameters to pass, and if there are any parameters, use his or not Just use 2
var number = number || 2;
// If you pass a string, convert it to a number span>
var f_change = fparseFloat(change)
return f_change.toFixed(number)
}
module.exports = {
floats: floats
}
"./wxs.wxs" module="info" /> {{info.floats(num)}}