wxs is a micro-channel to create a scripting language, it has its own grammar, and javaScript are not consistent, which is the official description of the micro-channel wxs, but after the fact to know, you will this is not a new language, it's just one kind is too restrictive, run the js in webview in specific reasons can view this article .
Its syntax is consistent and es5 js's, const let statement is not allowed, specific knowledge wxs grammar
use
Defined and used on wxml
<! - defined and used in wxml -> <Module1 WXS = "Data"> // definition module name module.exports = { EXP1: "throws 1" } </wxs> <View> // used herein {} {} data.exp1 </ View>
And the introduction of external use wxs
Wxs definition of a file, if the development does not have this option on the tool, create a new file directly into the suffix can wxs
//index1.wxs var foo = "hello world from tools.wxs"; module.exports={ foo:foo }
Used on wxml
<-! Module definition module name specified by src wxs address only accepts relative address ->
<Wxs module = "data" src = "./ index1.wxs" /> // import external wxs only define a single closing tag wxs
<view>
{{data.exp1}}
</view>
Scenes
Frequent user interaction, just change the style components (such as layout position) without changing the data content of the scene, such as sliding menu, index list, scroll gradients, a listing switching.
Purely logical calculations, such as text, date format,