MDN说:
请记住,
await关键字仅在async函数内部有效.如果你在一个async函数体外使用它,你会得到一个SyntaxError.
但事实并非如此.
在DevTools控制台中尝试此代码,没有错误,只是结果:
async function a(val) { return val; }
await a(10) // await is not inside async function
10
Run Code Online (Sandbox Code Playgroud)
代码或文档有什么问题?
javascript console asynchronous async-await google-chrome-devtools
例如-c,Ruby中有一个选项可以在运行代码之前检查语法:
C:\>ruby --help
Usage: ruby [switches] [--] [programfile] [arguments]
-c check syntax only
C:\>ruby -c C:\foo\ruby\my_source_code.rb
Syntax OK
Run Code Online (Sandbox Code Playgroud)
Go中是否有类似的功能?
PS Ruby的一个例子只是因为我在Ruby中知道它.不是因为拖钓或其他东西.
我有一个结构:
<div id="div">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg">
<image x="2cm" y="2cm" width="5cm" height="5cm" id="img" xlink:href="pic.jpg"></image>
</svg>
</div>
Run Code Online (Sandbox Code Playgroud)
我想得到pic.jpg网址,我需要从最外层的div开始,而不是完全来自source <image>元素:
var div = document.getElementById("div");
var svg = div.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'svg')[0];
var img = svg.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'image')[0];
var url = img.getAttribute('xlink:href'); // Please pay attention I do not use getAttributeNS(), just usual getAttribute()
alert(url); // pic.jpg, works fine
Run Code Online (Sandbox Code Playgroud)
我的问题是从SVG及其子元素等元素中获取此类属性的正确方法是什么?
因为在我尝试这种方式之前它在Chrome中运行良好(我没有尝试其他浏览器):
var svg = div.getElementsByTagName('svg')[0]; // I do not use NS
var img = svg.getElementsByTagName('image')[0];
var url = img.getAttribute('xlink:href'); // and do not …Run Code Online (Sandbox Code Playgroud) 该命令rails server抛出此错误.
C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': cannot load
such file -- mysql2/2.0/mysql2 (LoadError)
Run Code Online (Sandbox Code Playgroud)
我使用的红宝石2.0.0从RubyInstaller在Windows XP的方块.
我弄清楚问题是什么,但我不知道如何解决它.问题是gem中没有任何2.0/目录mysql2-0.3.11-x86-mingw32.这是rails从Gemfile安装为其依赖项的gem:
GEM
remote: https://rubygems.org/
specs:
... many gems here
mysql2 (0.3.11-x86-mingw32)
... many gems here
DEPENDENCIES
...
mysql2
...
Run Code Online (Sandbox Code Playgroud)
这是该mysql2.rb文件中的内容:
# C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\mysql2.rb
RUBY_VERSION =~ /(\d+.\d+)/
require "mysql2/#{$1}/mysql2" # <<-- this is that #2 line that throws an error
Run Code Online (Sandbox Code Playgroud)
很明显,它采用当前的Ruby版本号并将其用作路径段来访问某个mysql2文件.实际上它是mysql2.so文件.当我使用Ruby 2.0.0时,路径段是2.0:
mysql2/2.0/mysql2 …Run Code Online (Sandbox Code Playgroud) 我试图在XP上构建capybara-webkit.我按照这个指示.它说bundle install:
$ cd ruby193\capybara-webkit
$ bundle install
Run Code Online (Sandbox Code Playgroud)
这个命令安装了很多宝石.不幸的是我无法构建capybara-webkit所以我手动删除了它安装的所有宝石.这之后,我有问题,gem install并且bundle install-这些命令删除考虑宝石我的电脑上所安装和不安装他们,如果他们有一些其他的宝石我想现在安装的依赖关系.
请看一个例子.我做bundle install了capybara-webkit,它说,所有的宝石都存在:
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle install
Resolving dependencies...
Using rake (0.9.2)
Using addressable (2.3.2)
Using bundler (1.3.5)
Using appraisal (0.4.0)
Using mime-types (1.22)
Using nokogiri (1.5.9)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using xpath (2.0.0)
Using capybara (2.1.0)
Using json (1.8.0)
Using capybara-webkit (1.0.0) from source at .
Using ffi (1.2.0)
Using childprocess (0.3.6)
Using diff-lcs (1.1.2)
Using websocket …Run Code Online (Sandbox Code Playgroud) 我写的是Golang教程http://golang.org/doc/code.html#remote
我的环境设置:
C:\sbox\go\example>set go
GOPATH=C:\sbox\go\example
GOROOT=C:\Go
Run Code Online (Sandbox Code Playgroud)
该example/文件夹只有src/文件夹:
C:\sbox\go\example\
|
--src\
Run Code Online (Sandbox Code Playgroud)
现在我go get按照描述调用并得到一个错误:
C:\sbox\go\example>go get code.google.com/p/go.example/hello
# cd .; hg clone -U https://code.google.com/p/go.example C:\sbox\go\example\src\code.google.com\p\go.example
package code.google.com/p/go.example/hello: exec: "hg": executable file not found in %PATH%
Run Code Online (Sandbox Code Playgroud)
go get但是,在调用之后,我的example/文件夹就像这样:
C:\sbox\go\example\
|
--src\
|
code.google.com\
|
--p\
Run Code Online (Sandbox Code Playgroud)
就这样.没有安装更多.
然后我在我的目录结构中添加一个代码,它变成这样:
C:\sbox\go\example\
|
--src\
|
---code.google.com\
| |
| --p\
|
---github.com\
|
--user\
|
--hello\
| |
| --hello.go
|
--newmath\
|
--sqrt.go
Run Code Online (Sandbox Code Playgroud)
hello.go 是这样的:
package …Run Code Online (Sandbox Code Playgroud) 我安装了最新的Android SDK(22.3).但AVD Manager中没有"Nexus 5"选项.请看图片:

我应该选择何种方式来模拟Nexus 5?
我是Android开发新手.
我在Chrome中只收到此错误文字.没有任何其他信息:

这是什么意思?发生了什么?有没有办法告诉Angular或Chrome显示更详细的错误信息?
这是我的app.js文件.没有其他东西包括在内:
'use strict';
// Declare app level module which depends on filters, and services
var vsApp = angular.module('vsApp', [
'ngRoute',
'vsApp.filters',
'vsApp.services',
'vsApp.directives',
'vsApp.controllers'
]);
vsApp.config(["$routeProvider"], function($routeProvider) {
$routeProvider.when('/registration', {templateUrl: 'partials/reg.html', controller: 'regCtrl'});
$routeProvider.when('/login', {templateUrl: 'partials/login.html', controller: 'loginCtrl'});
$routeProvider.otherwise({redirectTo: '/'});
});
vsApp.controller("regCtrl", function() {});
vsApp.controller("loginCtrl", function() {});
Run Code Online (Sandbox Code Playgroud)
ng-app 属性包含:
<!DOCTYPE html>
<html ng-app="vsApp">
Run Code Online (Sandbox Code Playgroud)
我的<head>标签:
<script id="angularScript" src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-route/angular-route.js"></script>
<script src="/assets/js/app.js"></script>
Run Code Online (Sandbox Code Playgroud)
UPD:
量角器带来了更多信息:
Message:
UnknownError: unknown error: [$injector:modulerr] Failed to instantiate module vsApp due …Run Code Online (Sandbox Code Playgroud) 我希望有一个.scss文件包含所有其余.scss文件的一些varibles .但如果我这样做,它的.scss样式在我的所有.scss文件中都是重复的:
global.scss - 我的全局变量和样式文件
$white: #FFF;
$black: #000;
$bg_red: red;
.mt30 {
margin-top: 30px;
}
Run Code Online (Sandbox Code Playgroud)
header.scss - 我想在此文件中使用全局变量和样式.
@include "global"
.foo {
width: 100px;
height: 50px;
backgrounnd-color: $bg_red;
}
Run Code Online (Sandbox Code Playgroud)
main.scss - 我也想在这个文件中使用全局变量和样式.
@include "global"
.boo {
width: 100px;
height: 50px;
backgrounnd-color: $white;
}
Run Code Online (Sandbox Code Playgroud)
但每个最终.css文件都有来自global.scss的样式.所以.mt30我的页面上有几种样式.怎么避免呢?
是否可以在react-i18next字典中键入检查现有键?因此,如果密钥不存在,TS 会在编译时警告您。
例子。
假设,我们有这本字典:
{
"footer": {
"copyright": "Some copyrights"
},
"header": {
"logo": "Logo",
"link": "Link",
},
}
Run Code Online (Sandbox Code Playgroud)
如果我提供不存在的密钥,TS 应该会爆炸:
const { t } = useTranslation();
<span> { t('footer.copyright') } </span> // this is OK, because footer.copyright exists
<span> { t('footer.logo') } </span> // TS BOOM!! there is no footer.logo in dictionary
Run Code Online (Sandbox Code Playgroud)
这种技术的正确名称是什么?我很确定我不是唯一一个要求这种行为的人。
它是react-i18next开箱即用的吗?是否有 APIreact-i18next以某种方式扩展库以启用它?我想避免创建包装函数。
go ×2
javascript ×2
android ×1
angularjs ×1
async-await ×1
asynchronous ×1
console ×1
dom ×1
i18next ×1
mysql2 ×1
ruby-2.0 ×1
rubygems ×1
sass ×1
svg ×1
typescript ×1
xlink ×1