vue 导出功能
_createElement (entries) { let { tag, attr } = entries let node = document.createElement(tag) for (let key in attr) { node.setAttribute(key, attr[key]) } return node // fn && fn(node) // // 返回值只为了做测试用例 // return node ? true : false }, openForm (url, params, method) { console.log(url, params, method) const form = this._createElement(({ tag: 'form', attr: { id: 'newsForm', name: 'newsForm', target: '_blank', method: method, action: url } })) Object.keys(params).forEach(item=>{ let input = document.createElement('input') input.type = 'text' input.name = item input.value = params[item] form.appendChild(input) }) console.log(form) document.body.appendChild(form) form.submit() document.body.removeChild(form) }, // 导出 exportData () { const url = `${globalDefine.POST_URL}/manage/data/statistics/follow/export/${this.type}` this.openForm(url, this.params, "POST") },
越努力越幸运