如何通过类,id,selectors(div > .my-i
)和jQuery中的属性获取DOM元素?
例如:
<div class="myClass" style="width:200px">
<span id="pop">test</span>
<div>
<i>aaa</i>
<i class="my-i">bbb</i>
<i class="my-i">ccc</i>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要得到:
什么是最好的方式?
我在尝试:
.post("/getAttachments", (req, res, next) => {
repository.getAttachments(req.body)
.then((attachment) => {
return res.sendFile('https://host.com' + attachment.req.path);
})
.catch(next);
})
///clientService:
function getAttachments(params) {
return $http.post(baseUrl + "/getAttachments", params, {responseType: 'arraybuffer'}).success(function (data) {
let blob = new Blob([data], {type: 'application/vnd.ms-excel'});
saveAs(blob);
});
};
Run Code Online (Sandbox Code Playgroud)
所有都适用于本地文件.你能帮忙吗?
阅读包括“ Access-Control-Allow-Origin”在内的许多方法,但没有一种对我有用。
我使用@ angular / common / http模块和外部url作为数据源。通过尝试获取数据来获取错误:///// .................
Failed to load http://accounts.......com/accounts: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 503.
Run Code Online (Sandbox Code Playgroud)
account.service.ts:
Failed to load http://accounts.......com/accounts: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 503.
Run Code Online (Sandbox Code Playgroud)
app.module.ts
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { HttpClient, …
Run Code Online (Sandbox Code Playgroud)