和楼主一样的发现,关注下
小程序开发 显示 snsvideodownload 请求在使用开发的工具的时候,发现会先有一个 请求:http://wxsnsdythumb.wxs.qq.com/109/20204/snsvideodownload?m=127e353c0a9bb8ec60aa40e2f94d51df&filekey=3033020101041f301d02016d040253480410127e353c0a9bb8ec60aa40e2f94d51df020204f2040d00000004627466730000000131&hy=SH&storeid=32303139303432343135353431363030306631383661313336666664393337303561333230613030303030303664&bizid=1023 但是在开发中并没有使用到相应的功能代码
2019-08-02解决了。 [代码]function[代码] [代码]getCategoryList(pageObj) {[代码][代码] [代码][代码]let that = pageObj;[代码][代码] [代码][代码]that.data.data1.forEach((item, index) => {[代码][代码] [代码][代码]if[代码] [代码](item.enTitle) {[代码] [代码] [代码][代码]let trade = item.enTitle;[代码] [代码] [代码][代码]util.request(`${api.getCategoryList}?trade=${trade}`).then(res => {[代码][代码] [代码][代码]let childModel = [];[代码][代码] [代码][代码]res.data.forEach((item2, index2) => {[代码][代码] [代码][代码]let childModelElement = {[代码][代码] [代码][代码]id: `${index}-${index2 + 1}`, [代码][代码]// '1-1',[代码][代码] [代码][代码]title: item2[代码][代码] [代码][代码]};[代码][代码] [代码][代码]childModel.push(childModelElement);[代码][代码] [代码][代码]}); [代码][代码]// res.data.forEach[代码][代码] [代码][代码]console.log([代码][代码]'——————————childModel: '[代码][代码], childModel); [代码][代码]// 调试用[代码][代码] [代码][代码]that.data.data1[index].childModel = that.data.data1[index].childModel.concat(childModel);[代码][代码] [代码][代码]// let data1Name = 'that.data.data1[' + index + '].childModel';[代码][代码] [代码][代码]// that.setData({[代码][代码] [代码][代码]// [data1Name]: that.data.data1[index].childModel.concat(childModel)[代码][代码] [代码][代码]// })[代码][代码] [代码][代码]console.log([代码][代码]'——————————that.data.data1[index]: '[代码][代码], that.data.data1[index]); [代码][代码]// 调试用[代码][代码] [代码][代码]}).then(() => {[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]data1: that.data.data1[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log([代码][代码]'——————————that.data.data1: '[代码][代码], that.data.data1); [代码][代码]// 调试用[代码][代码] [代码][代码]}); [代码][代码]// util.request[代码] [代码] [代码][代码]} [代码][代码]// if (item.enTitle)[代码][代码] [代码][代码]}); [代码][代码]// forEach[代码][代码]}[代码]汗颜。要更深刻的理解异步的概念。
父页面传递给组件的数据变更,子组件监控不到。父页面wxml: [代码]<[代码][代码]dropdownmenu[代码] [代码]wx:if[代码][代码]=[代码][代码]"{{currentTabIndex === 0}}"[代码] [代码]dropDownMenuTitle[代码][代码]=[代码][代码]'{{dropDownMenuTitle}}'[代码] [代码]dropDownMenuDistrictData[代码][代码]=[代码][代码]'{{data1}}'[代码] [代码]dropDownMenuFilterData[代码][代码]=[代码][代码]'{{data2}}'[代码] [代码]bind:selectedItem[代码][代码]=[代码][代码]'selectedItem'[代码][代码]/>[代码][图片] 父页面js: data1一级菜单是写死的就2个。 [代码]data: {[代码][代码] [代码][代码]data1: [{[代码][代码] [代码][代码]id: 0,[代码][代码] [代码][代码]title: [代码][代码]'不限'[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]id: 1,[代码][代码] [代码][代码]title: [代码][代码]'汽修'[代码][代码],[代码][代码] [代码][代码]enTitle: [代码][代码]'qixiu'[代码][代码],[代码][代码] [代码][代码]childModel: [][代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]id: 2,[代码][代码] [代码][代码]title: [代码][代码]'汽配'[代码][代码],[代码][代码] [代码][代码]enTitle: [代码][代码]'qipei'[代码][代码],[代码][代码] [代码][代码]childModel: [][代码][代码] [代码][代码]}[代码][代码] [代码][代码]],[代码][代码]}[代码]data1二级菜单是动态获取的。 [代码]getCategoryList() {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]topicApi.getCategoryList(that);[代码][代码] [代码][代码]},[代码]topicApi中的getCategoryList方法 [代码]function[代码] [代码]getCategoryList(pageObj) {[代码][代码] [代码][代码]let that = pageObj;[代码][代码] [代码][代码]that.data.data1.forEach((item, index) => {[代码][代码] [代码][代码]if[代码] [代码](item.enTitle) {[代码] [代码] [代码][代码]let trade = item.enTitle;[代码] [代码] [代码][代码]util.request(`${api.getCategoryList}?trade=${trade}`).then(res => {[代码][代码] [代码][代码]let childModel = [];[代码][代码] [代码][代码]res.data.forEach((item2, index2) => {[代码][代码] [代码][代码]let childModelElement = {[代码][代码] [代码][代码]id: `${index}-${index2 + 1}`, [代码][代码]// '1-1',[代码][代码] [代码][代码]title: item2[代码][代码] [代码][代码]};[代码][代码] [代码][代码]childModel.push(childModelElement);[代码][代码] [代码][代码]}); [代码][代码]// res.data.forEach[代码][代码] [代码][代码]console.log([代码][代码]'——————————childModel: '[代码][代码], childModel); [代码][代码]// 调试用[代码][代码] [代码][代码]that.data.data1[index].childModel = that.data.data1[index].childModel.concat(childModel);[代码][代码] [代码][代码]console.log([代码][代码]'——————————that.data.data1[index]: '[代码][代码], that.data.data1[index]); [代码][代码]// 调试用[代码][代码] [代码][代码]}); [代码][代码]// util.request[代码] [代码] [代码][代码]} [代码][代码]// if (item.enTitle)[代码][代码] [代码][代码]}); [代码][代码]// forEach[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]data1: that.data.data1[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log([代码][代码]'——————————that.data.data1: '[代码][代码], that.data.data1); [代码][代码]// 调试用[代码][代码]}[代码]子组件相关代码: [代码]Component({[代码][代码] [代码][代码]properties: {[代码][代码] [代码][代码]dropDownMenuDistrictData: {[代码][代码] [代码][代码]type: Array,[代码][代码] [代码][代码]value: [],[代码][代码] [代码][代码]observer: [代码][代码]function[代码] [代码](newVal, oldVal) {[代码][代码] [代码][代码]console.log([代码][代码]'——————————属性改变了, new, old: '[代码][代码], newVal, oldVal); [代码][代码]// 调试用[代码][代码] [代码][代码]console.log([代码][代码]'——————————this.properties.dropDownMenuDistrictData: '[代码][代码], [代码][代码]this[代码][代码].properties.dropDownMenuDistrictData);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] }[代码][代码]}[代码] 问题,当data1固定值时,显示是正常的。 [图片][图片] 而当data1是我如上面代码是动态的时候,显示就为空。主要是属性变更无法监控到,网络请求还在属性变更之后。打印的日志如下。 [图片] 求懂的人指点一二,跪谢
2019-07-13