import language from "./common/language.js"; import Service from "./common/service.js"; new Vue({ el: "#app", data: { info: {}, }, mounted() { const id = location.href.split("?id=")[1]; this.getDetail(id); }, methods: { text(val) { return language[val][localStorage.getItem("language")]; }, lan_key(val) { return `${val}${localStorage.getItem("language") == "en" ? "_en" : ""}`; }, getDetail(id) { Service.get_news_detail({ id }) .then((res) => { this.info = res; }) .catch((err) => { console.log(err); }); }, downloadFile() { const a = document.createElement("a"); a.href = Service.baseURL + this.info.url; a.download = decodeURI(this.info[this.lan_key("url_name")] + ".docx"); document.body.appendChild(a); a.click(); document.body.removeChild(a); // 下载完移除元素 }, back() { history.go(-1); }, }, });