const app = getApp(); Component({ properties: { course_id:Number, id_:Number, refresh:{ type:Number, observer:function(r){ if (r) { console.log("observer refresh") this.refresh(); this.setData({ refresh: false }); } } } }, data: { list:[{text:"全部",order:""},{text:"未发布",order:0},{text:"提交中",order:1},{text:"补交中",order:2},{text:"匿评中",order:3},{text:"申诉中",order:4},{text:"已截止",order:5}] }, attached(){ this.refresh(); }, methods: { onSwitchNav({detail:{current, value}}){ console.log("switchNav") if(!this.options) this.options={}; this.options.order=value.order; this.refresh(); }, refresh(){ let {course_id} = this.data; console.log(this.options); app.api("courses.homework_commons")({...this.options, course_id, type:1}) .then(res=>{ console.log(res); this.setData({homeworks: res.homeworks}); }).catch(e=>{ app.showError(e); console.error(e); }) } } })