var app = new Vue({ el: '#app', data: { id: null, columnList:[], bbb:'', array: [], //解决方案旧 solutionArray: [], //解决方案详情数据 solutionTypes: [], //解决方案类型 }, computed: { }, created: function () { }, mounted: function () { _this = this this.getColumnData() //解决方案旧 $.ajax({ type: 'POST', dataType: 'json', url: window.FQDN + 'Solution/index', data: { id: '1' } }).done(function (arr) { _this.array = arr; console.log(_this.array) }).fail(function (err) {}); }, methods: { //获取内容 getArticalData(param) { $.ajax({ type: 'GET', dataType: 'json', url: window.FQDN2 + 'siteArticle/siteArticleList', data: { categoryid: param } }).done(function (res) { console.log(res); var aa = res.data.records aa.sort(_this.compare("lmtitle")) _this.solutionArray = aa }).fail(function (err) {}); }, //获取栏目 getColumnData() { $.ajax({ type: 'get', dataType: 'json', url: window.FQDN2 + 'siteCategory/siteCategoryList', }).done(function (res) { _this.columnList=res.data; _this.bbb=window.location.pathname for (let i = 0; i < res.data.length; i++) { console.log(res.data[i].sname) console.log(window.location.pathname) if (res.data[i].children.length > 0) { if (res.data[i].categoryName == '解决方案') { _this.solutionTypes = res.data[i].children _this.id = _this.getQueryVariable('id') ? _this.getQueryVariable('id') : _this.solutionTypes[0].id; _this.getArticalData(_this.id ? _this.id : _this.solutionTypes[0].id) } } } }) }, // 排序 compare(property) { return function (a, b) { var value1 = a[property]; var value2 = b[property]; return value1 - value2; } }, //解决方案类型点击 facilityClick(e, item) { this.id = item.id this.getArticalData(item.id) console.log(item.id) }, //获取路由参数 getQueryVariable: function (variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return (false); } } });