- 信小程序(與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);
}
})
}

