const util = require('../../utils/util.js'); Component({ properties: { aid: { type: String, observer: function(newVal) { this.setData({ aid: newVal }); this.getRecommend(); } } }, data: { imgUrl: util.config.imgPath, recommendList: [] }, methods: { getRecommend() {//获取推荐 let that = this; util.ajax({ func: "article/recommend", data: { "aid": (that.data.aid == -1 ? '' : that.data.aid) || '' }, load: false }, function (res) { if(res.code == 0) { that.setData({ recommendList: res.data ? res.data.recommendList : [] }); } }) } } })