• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

微信小程序之---- 数据处理

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
exports 关键字
     .wxs 通过该属性,可以对外共享本模块的私有变量与函数
 
使用步骤
1. 在 .wxs后缀文件 exports定义参数
var foo = "'hello world' from comm.wxs"; var bar = function(d) { return d; } module.exports = { foo: foo, bar: bar };
2. 在 .wxml 后缀文件引入 .wxs文件,直接使用变量
<wxs src="./../tools.wxs" module="tools" /> <view> {{tools.msg}} </view> <view> {{tools.bar(tools.FOO)}} </view>
 
require 关键字  
 
      var foo = "'hello world' from tools.wxs";
        var bar = function (d) { return d; }
       module.exports = { FOO: foo, bar: bar, };
       module.exports.msg = "some msg";
        // /pages/logic.wxs
        var tools = require("./tools.wxs");
         console.log(tools.FOO);
        console.log(tools.bar("logic.wxs"));
       console.log(tools.msg);
  <!-- /page/index/index.wxml -->
  <wxs src="./../logic.wxs" module="logic" />
  wxs标签可直接在模版中使用
  
<wxs module="foo"> var some_msg = "hello world"; module.exports = { msg : some_msg, } </wxs> <view> {{foo.msg}} </view>
wxs 标签的两种属性
modules 和 src 属性
 
 
  微信小程序常用的数据处理语句
  if /else switch case for while
 
数据类型
  • number : 数值
  • string :字符串
  • boolean:布尔值
  • object:对象
  • function:函数
  • array : 数组
  • date:日期
  • regexp:正则
 
number 使用方法
使用方法
  • toString
  • toLocaleString
  • valueOf
  • toFixed
  • toExponential(指数计数)
  • toPrecision(方法可在对象的值超出指定位数时将其转换为指数计数法)
 
string 使用方法
  • toString
  • valueOf
  • charAt
  • charCodeAt
  • concat
  • indexOf
  • lastIndexOf
  • localeCompare
  • match
  • replace
  • search
  • slice
  • split
  • substring
  • toLowerCase
  • toLocaleLowerCase
  • toUpperCase
  • toLocaleUpperCase
  • trim
 
boolean 使用方法
布尔值只有两个特定的值:true 和 false。
  • valueOf
  • toString
 
 
object 使用方法
  • toString:返回字符串 "[object Object]"。
 
 
function 使用方法
  • length: 传递给函数的参数个数。
  • [index]: 通过 index 下标可以遍历传递给函数的每个参数。
 
 
array使用方法
属性
  • constructor:返回字符串 "Array"。
  • length
方法
  • toString
  • concat
  • join
  • pop
  • push
  • reverse
  • shift
  • slice
  • sort
  • splice
  • unshift
  • indexOf
  • lastIndexOf
  • every
  • some
  • forEach
  • map
  • filter
  • reduce
  • reduceRight
 最后打开支付宝首页搜“522158734”领红包,领到大红包的小伙伴赶紧使用哦!
O(∩_∩)O哈哈~
 
 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
EA&amp;UML日拱一卒-0基础学习微信小程序(10)-注册页面发布时间:2022-07-18
下一篇:
小程序的view层发布时间:2022-07-18
热门推荐
    热门话题
    阅读排行榜

    扫描微信二维码

    查看手机版网站

    随时了解更新最新资讯

    139-2527-9053

    在线客服(服务时间 9:00~18:00)

    在线QQ客服
    地址:深圳市南山区西丽大学城创智工业园
    电邮:jeky_zhao#qq.com
    移动电话:139-2527-9053

    Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap