zoukankan      html  css  js  c++  java
  • wepy

    app.js和app.wpy有什么不同呢?

    答.app.wpy单文件包含了app.wxssapp.jsapp.jsonapp.wxml

    app.js

     1 App({
     2 
     3   /**
     4    * 当小程序初始化完成时,会触发 onLaunch(全局只触发一次)
     5    */
     6   onLaunch: function () {
     7     
     8   },
     9 
    10   /**
    11    * 当小程序启动,或从后台进入前台显示,会触发 onShow
    12    */
    13   onShow: function (options) {
    14     
    15   },
    16 
    17   /**
    18    * 当小程序从前台进入后台,会触发 onHide
    19    */
    20   onHide: function () {
    21     
    22   },
    23 
    24   /**
    25    * 当小程序发生脚本错误,或者 api 调用失败时,会触发 onError 并带上错误信息
    26    */
    27   onError: function (msg) {
    28     
    29   }
    30 })

    app.wpy

      1 <style lang="less">
      2 @import './font/iconfont.less';
      3 page {
      4   height: 100%;
      5   background-color: #fff;
      6 }
      7 </style>
      8 
      9 <script>
     10 import wepy from 'wepy';
     11 import 'wepy-async-function';
     12 
     13 export default class extends wepy.app {
     14   config = {
     15     pages: [
     16       'pages/ep/ep',
     17       'pages/forexpress',
     18       'pages/bill/addone',
     19       'pages/plan',
     20       'pages/plan/clock',
     21       'pages/bill',
     22       'pages/me',
     23       'pages/me/about',
     24       'pages/me/planT',
     25       'pages/me/billT',
     26       'pages/index/index',
     27       'pages/expressJump/expressJump',
     28       'pages/share/share',
     29       'pages/me/edit',
     30       'pages/weather',
     31       'pages/historytoday',
     32       'pages/game/index',
     33       'pages/testYun/index'
     34     ],
     35     window: {
     36       backgroundTextStyle: 'light',
     37       navigationBarBackgroundColor: '#138cff',
     38       navigationBarTitleText: 'WeChat',
     39       navigationBarTextStyle: 'white',
     40       backgroundColor: '#138cff'
     41     },
     42     tabBar: {
     43       color: '#757982',
     44       selectedColor: '#138cff',
     45       borderStyle: 'white',
     46       backgroundColor: '#fff',
     47       list: [
     48         {
     49           pagePath: 'pages/plan',
     50           text: '计划',
     51           iconPath: 'images/tabbar/plan.png',
     52           selectedIconPath: 'images/tabbar/plan-on.png'
     53         },
     54         {
     55           pagePath: 'pages/bill',
     56           text: '账本',
     57           iconPath: 'images/tabbar/bill.png',
     58           selectedIconPath: 'images/tabbar/bill-on.png'
     59         },
     60         {
     61           pagePath: 'pages/forexpress',
     62           text: '快递',
     63           iconPath: 'images/tabbar/index.png',
     64           selectedIconPath: 'images/tabbar/index-on.png'
     65         },
     66         {
     67           pagePath: 'pages/weather',
     68           text: '天气',
     69           iconPath: 'images/tabbar/weather.png',
     70           selectedIconPath: 'images/tabbar/weather-on.png'
     71         },
     72         {
     73           pagePath: 'pages/me',
     74           text: '我的',
     75           iconPath: 'images/tabbar/me.png',
     76           selectedIconPath: 'images/tabbar/me-on.png'
     77         }
     78       ]
     79     }
     80   };
     81 
     82   globalData = {
     83     userInfo: null,
     84     info: {
     85       name: 11
     86     }
     87   };
     88 
     89   constructor() {
     90     super();
     91     this.use('requestfix');
     92     this.use('promisify');
     93   }
     94 
     95   onLaunch() {
     96     this.testAsync();
     97     Date.prototype.getWeek = function(days) {
     98       let week = [
     99         '星期天',
    100         '星期一',
    101         '星期二',
    102         '星期三',
    103         '星期四',
    104         '星期五',
    105         '星期六'
    106       ];
    107       return week[new Date(this).getDay()];
    108     };
    109   }
    110 
    111   sleep(s) {
    112     return new Promise((resolve, reject) => {
    113       setTimeout(() => {
    114         resolve('promise resolved....');
    115       }, s * 1000);
    116     });
    117   }
    118 
    119   async testAsync() {
    120     const data = await this.sleep(3);
    121     console.log('打印数据:', data);
    122   }
    123 
    124   getUserInfo(cb) {}
    125 }
    126 </script>
  • 相关阅读:
    如何控制input框!
    火车头采集器破解版
    记Angular与Django REST框架的一次合作(2):前端组件化——Angular
    拉勾网一些“震惊”的结论
    一个知乎重度用户眼中的知乎
    anthelion编译
    搜索引擎爬虫蜘蛛的USERAGENT大全
    Netty系列之Netty高性能之道
    python正则表达式
    Cookie的使用,详解,获取,无法互通、客户端获取Cookie、深入解析cookie
  • 原文地址:https://www.cnblogs.com/cisum/p/9879897.html
Copyright © 2011-2022 走看看