我正在使用最新的Firebase JS api(来自firebase.google.com的 API )到我的Ionic/cordova应用程序,我曾经通过在index.html文件中插入代码来导入它:<script src="https://www.gstatic.com/firebasejs/3.0.0/firebase.js"></script>.这就是我用来在controllers.js中初始化Firebase的方式(我正在使用AngularJS):
firebase.initializeApp(config);
Run Code Online (Sandbox Code Playgroud)
但是,在localhost上启动应用程序到我的浏览器后:我总是得到以下错误:
错误:此域未获授权用于Firebase项目的OAuth操作.从Firebase控制台编辑授权域列表.
firebase.js:71:1333
我偶然发现了这个"编程"语言列表,发现像Python这样的流行语言没有标准化?为什么会这样,"标准化"是什么意思?
我想在同一个请求中实现post文件和Json数据.
以下是上传文件代码:
upload(url:string,file:File):Observable<{complate:number,progress?:number,data?:Object}>{
return Observable.create(observer => {
const formData:FormData = new FormData(),
xhr:XMLHttpRequest = new XMLHttpRequest();
formData.append('uploadfile', file);
formData.append("_csrf", this.tokenService.getCsrf());
xhr.open('POST',url, true);
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
observer.next({complate:1,progress:100,data:JSON.parse(xhr.response)});
observer.complete();
} else {
observer.error(xhr.response);
}
}
};
xhr.upload.onprogress = (event) => {
observer.next({complate:0,progress:Math.round(event.loaded / event.total * 100)});
};
const headers=new Headers();
let token: string = localStorage.getItem('access-token');
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
xhr.send(formData);
}).share();
Run Code Online (Sandbox Code Playgroud)
如何与angular2 http.post(url,JSON.stringify(data))集成.
我有以下 webpack 配置:
module.exports = {
entry: "./src/index.js",
output: {
path: __dirname + '/dist',
// publicPath: __dirname + '/dist/',
filename: "bundle.js"
},
devServer: {
contentBase: "/dist",
hot: true,
}
}
Run Code Online (Sandbox Code Playgroud)
我的理解是contentBase告诉 webpack 开发服务器从哪里提供文件。因此,如果我转到localhost:8080/test.txt,在此配置下,文件 atmyProjectRoot/dist/test/txt将由服务器发送到浏览器。那是对的吗?这一切有什么output.publicPath关系呢?
现在我已经index.html坐在bundle.js那里了myProjectRoot/dist/。(尽管我认为bundle.js这有点令人困惑,因为它实际上是由 webpack-dev-server 返回的内存包,但尽管如此)。根据我之前的段落,我希望服务器返回index.html到浏览器。由于contentBaseis/dist和index.html在磁盘上的路径是./dist/index.html.
但我却看到:Cannot GET /
所以,如果我再次访问,http://localhost:8080/bundle.js我会看到完整的 javascript 包(与我的文本编辑器中最后保存的内容是最新的)。但后来/index.html赢了Cannot GET /?
我缺少什么?
伪代码下面描述了我的组件树结构.
<app-root>
<router-outlet name="main">
<Home-component>
<a routerLink="about">About</a> //
<router-outlet name="home"> </<router-outlet>
</Home-component>
</router-outlet>
</app-root>
Run Code Online (Sandbox Code Playgroud)
当用户点击"关于"链接时,关于组件显示在"主"路由插座中,但我的目的是将其显示在"家"路由器插座中,需要修改以实现该目的.
"app-root"组件和"Home-component"是根模块的一部分,"AboutComponent"是功能模块的一部分.
根模块路由如下.
RouterModule.forRoot([
{path:'' , component:LoginComponent },
{path:'home' , component:HomeComponent}
]),
Run Code Online (Sandbox Code Playgroud)
和功能模块路由如下...
RouterModule.forChild([
{path:'about' , component:AboutComponent }
])
Run Code Online (Sandbox Code Playgroud) 我正在使用Angular 入门套件
我正在尝试让 tslint 使用 --fix 标志自动修复我所有的 lint 问题。
我正在运行脚本:
npm run tslint --fix src/**/*.ts
它只会生成与我已经被告知的相同错误,tslint而不是自动修复它:
控制台输出:
ERROR: src/app/app-routing.module.ts[10, 5]: comment must start with a space
ERROR: src/app/app-routing.module.ts[2, 20]: Too many spaces before 'from'
Run Code Online (Sandbox Code Playgroud)
我是否缺少允许它实施更改的东西?
我的版本是:
"tslint": "^5.6.0"
"codelyzer": "^3.1.2"
Run Code Online (Sandbox Code Playgroud)
问题:如何让 tslint 对我的 lint 错误实施自动修复?
我想实现一个功能的"添加",结合列表L1与L2到L3:
def add(L1,L2,L3):
L3 = L1 + L2
L3 = []
add([1],[0],L3)
print L3
Run Code Online (Sandbox Code Playgroud)
上面的代码生成一个空列表而不是[1,0]- 这意味着L3没有通过引用传递.
如何L3通过参考传递?
我正在创建打字稿基础 npm 模块,但我坚持玩笑测试。我正在尝试包含来自https://github.com/types/jsonld 的jsonld 模块,一切似乎都正常,但是当我运行命令时yarn test出现错误消息Cannot find module 'jsonld' from 'DidDocument.ts'
包.json
{
"name": "defined-id",
"version": "1.0.0",
"description": "Defined ID",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "jest --config jestconfig.json",
"build": "tsc",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lint": "tslint -p tsconfig.json",
"prepare": "yarn run build",
"prepublishOnly": "yarn test && yarn run lint",
"preversion": "yarn run lint",
"version": "yarn run format && git add -A src",
"postversion": "git push && git push --tags"
},
"repository": { …Run Code Online (Sandbox Code Playgroud) 我试图div在我的 HTML 中水平对齐两个s:第一个包含图像,第二个包含文本,这是使用的代码:
<div style="float: left; width: 55px;">
<img src="../img/look.svg" alt="">
</div>
<div style="display: inline-block;">
<span> Look for cases </span>
<span> from people near you. </span>
</div>Run Code Online (Sandbox Code Playgroud)
我尝试了很多方法,但我一直无法获得与图像垂直轴相同级别的文本行,并且第二个内部的文本div显示的垂直距离图像很远。
那么,有没有可能解决这个问题?
我正在尝试更改以下 html 文档中标题的值:
<html lang="en">
<head>
<meta charset="utf-8">
<title id="title"></title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<app-root></app-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
为了完成任务,我编写了以下使用 lxml 的 python 脚本:
from lxml.html import fromstring, tostring
from lxml.html import builder as E
html = fromstring(open('./index.html').read())
html.replace(html.get_element_by_id('title'), E.TITLE('TEST'))
Run Code Online (Sandbox Code Playgroud)
但运行脚本后,出现以下错误:
ValueError:元素不是此节点的子节点。
应该是什么原因导致这个错误?谢谢。
python ×3
typescript ×3
angular ×2
html ×2
codelyzer ×1
cors ×1
css ×1
file-upload ×1
firebase ×1
javascript ×1
jestjs ×1
json-ld ×1
lxml ×1
mobile ×1
npm-scripts ×1
oauth ×1
standardized ×1
tslint ×1
types ×1