码迷,mamicode.com
首页 > 微信 > 详细

微信小程序视图层WXS_变量

时间:2018-07-05 19:43:42      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:class   wxs   type   规则   字母   break   argument   lse   efault   

微信小程序视图层WXS_小程序变量

微信小程序变量的概念

  • WXS 中的变量均为值的引用。
  • 没有声明的变量直接赋值使用,会被定义为全局变量。
  • 如果只声明变量而不赋值,则默认值为 undefined。
  • var表现与javascript一致,会有变量提升。
var foo = 1;
var bar = "hello world";
var i; // i === undefined

上面代码,分别声明了 foo、 bar、 i 三个变量。然后,foo 赋值为数值 1 ,bar 赋值为字符串 "hello wolrd"。

变量名

微信小程序的变量命名必须符合下面两个规则:

  • 首字符必须是:字母(a-zA-Z),下划线(_)
  • 剩余字符可以是:字母(a-zA-Z),下划线(_), 数字(0-9)

保留标识符

以下标识符不能作为

微信小程序

的变量名:

delete 
void 
typeof

null 
undefined 
NaN 
Infinity 
var

if 
else 

true 
false

require

this 
function 
arguments
return

for
while
do
break
continue
switch
case
default

微信小程序视图层WXS_变量

标签:class   wxs   type   规则   字母   break   argument   lse   efault   

原文地址:https://www.cnblogs.com/lanshu/p/9269900.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!