在index里面引入一个template,然后将模板里面的方法注入到index上,在开发者工具中正常运行,发布到真机测试时提示下列错误
代码如下:
let _infoEvent = { '__info__descClick' : function(e){ //当前点击的序号 let sqnm = e.target.dataset.sqnm; if(undefined == sqnm) return; let descText = this.data.customerDescArr[sqnm]; let phoneList = this.data.phoneList[this.data.callSqnm]; phoneList.desc = phoneList.desc || []; let descChoiceList = this.data.configInfo.descChoiceList; let index = phoneList.desc.indexOf(descText); if(-1 == index) { phoneList.desc.push(descText) descChoiceList[sqnm].type = 'cancel'; } else { phoneList.desc.splice(index, 1); descChoiceList[sqnm].type = 'success_circle'; } this.setData({ phoneList : this.data.phoneList, 'configInfo.desc' : phoneList.desc, 'configInfo.descChoiceList' : descChoiceList }) }, '__info__stateClick' : function(e){ //当前点击的序号 let sqnm = e.target.dataset.sqnm; if(undefined == sqnm) return; let phoneList = this.data.phoneList[this.data.callSqnm]; let stateText = this.data.customerStateArr[sqnm]; let index = phoneList.state.indexOf(stateText); let state = this.data.configInfo.state; if( -1 == index ){ phoneList.state.push(stateText); state[sqnm].flag = 'yes'; } else { phoneList.state.splice(index, 1); state[sqnm].flag = 'no'; } this.setData({ phoneList : this.data.phoneList, 'configInfo.state' : state }) }}function InfoPannel(){ // 拿到当前页面对象 let pages = getCurrentPages() let curPage = pages[pages.length - 1] // navPannel = new NavPannel(curPage); // 把组件的事件“合并到”页面对象上 Object.assign(curPage, _infoEvent) this.__page = curPage // curPage.navPannel = this // 把组件的数据“注入”到页面的data对象中 // curPage.setData(_compData); return this}module.exports = { InfoPannel} |
求大神解救呀

iOS 真机上还不支持 Object.assign(ES6 新 API)导致的,这个问题我们很快就会解决,当前可以先手动打个 polyfill
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill