• 信小程序(与js)通过requirejs引用外部js文件

var modelSearch = require('../../utils/modelSearch.js') 这是一个构建数据请求筛选条件的库文件

需要在modelSearch中暴露出函数 使用导出函数对象将函数导出到接收对象

module.exports.GetWhereAndOrderBy = GetWhereAndOrderBy;

module.exports.whereOptionAll = whereOptionAll;

module.exports.SearchAjaxPage = SearchAjaxPage;
module.exports.GetOption=GetOption;
module.exports.NoNull=NoNull;

使用module.exports导出函数

 

  • 使用api接口请求异步数据  

 

使用微信提供的api函数 使用方法与jq的Ajax函数类似

var urlHead='http://120.236.148.71:108/';
function SearchAjaxPage(getType, whereStr,callFn) {
 
   wx.request({
  url: urlHead+ '/PublicData/' + getType + '?where=' + whereStr, //仅为示例,并非真实的接口地址
  data: {
   
  },
  header: {
      'content-type': 'application/json'
  },
  success: function(res) {
    callFn(res);
  }
})

  


}

  

 

posted on 2017-05-17 09:56  xuelei被占用了  阅读(2775)  评论(0编辑  收藏  举报