我想向我的 Blob 文件添加一个文件名,但我真的不知道该怎么做,这是我目前的代码:
onClick() {
var myHeader = new Headers();
myHeader.append('Content-Type', 'text/plain');
fetch(this.props.url, {
method: 'POST',
headers: myHeader,
body: JSON.stringify(this.state.api_arg)
}).then(response => {
const filename = getFileName(response.headers.get('Content-Disposition'))
response.blob().then(myBlob => {
const fileUrl = URL.createObjectURL(myBlob)
console.log(fileUrl)
window.open(fileUrl)
})
})
}
Run Code Online (Sandbox Code Playgroud)
我的文件名存储在一个变量中。
我想在主体中添加一个div运行时,如下所示:
<div>{{test}}</div>
Run Code Online (Sandbox Code Playgroud)
它应该从Angular代码外部添加,例如单击按钮时.所以,没有指令,只是添加div.也许是简单的问题,但我无法在网上找到答案.
有
function TodoCtrl($scope) {
$scope.totalTodos = 4;
}
<body ng-app ng-controller="TodoCtrl">
<span>{{test}}</span> <!-- already works -->
</body>
Run Code Online (Sandbox Code Playgroud) 我正在使用moment.js而我无法更改默认语言环境:
moment.locale('fr');
console.log(moment.locale()); // en
Run Code Online (Sandbox Code Playgroud)