我不明白为什么我一次又一次地出现这个错误......当我有一个新的提供者时。当我有任何其他提供商(如地理定位等)时,出现此错误:
错误:未捕获的错误:NgModule 'AppModule' 的提供程序无效 - 仅允许提供程序和类型的实例,得到:[StatusBar, SplashScreen,?[object Object]?, ...]
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { ImagePicker } from '@ionic-native/image-picker';
import { Crop } from '@ionic-native/crop';
import { AuthService } from '../pages/core/auth.service';
import { UserService } from '../pages/core/user.service';
import { FollowService } from "../pages/core/follow.service";
import { AngularFireModule } from 'angularfire2';
import { …Run Code Online (Sandbox Code Playgroud) 当我尝试在“地点自动完成”中搜索时,出现“无法加载搜索结果” 并且日志显示
“自动填充时出错:OVER_QUERY_LIMIT”
我已启用https://console.cloud.google.com/, 并且API密钥运行良好。
Java代码
String apiKey = "MY API KEY";
private RadioGroup mRadioGroup;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_costumer_map);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
Places.initialize(getApplicationContext(), apiKey);
PlacesClient placesClient = Places.createClient(this);
// Initialize the AutocompleteSupportFragment.
AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)
getSupportFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
// Specify the types of place data to return.
autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));
// Set up a PlaceSelectionListener to handle the response. …Run Code Online (Sandbox Code Playgroud) List returnMovies = [];
Future<List> _getData() async {
final response = await http.get("https:../getTodayMovies",
headers: {HttpHeaders.AUTHORIZATION: Acess_Token.access_token});
if (response.body != null) {
returnMovies = json.decode(response.body);
.....
setState(() {});
} else {
final responseUpcoming = await http.get("/upcoming",
headers: {HttpHeaders.AUTHORIZATION: Acess_Token.access_token});
returnMovies = json.decode(responseUpcoming.body);
}
Run Code Online (Sandbox Code Playgroud)
response.body 看起来像:
[{"id":394470548,"host_group_name":"heyab redda","movie_image":"..png","type":"horror","code":"X123","name":"Lovely","start_time":1554364800,"end_time":1554393600,"}]
Run Code Online (Sandbox Code Playgroud)
responseUpcoming.body 看起来像:
{"id":394470545,"host_group_name":"foo redda","movie_image":".png","type":"horror","code":"X123","name":"Lovely","start_time":1554364800,"end_time":1554393600,"}, {"id":394470548,"host_group_name":"foo1 redda","movie_image":"..png","type":"comic","code":"X125","name":"Lovely1","start_time":1554364800,"end_time":1554393600,"}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是: String, dynamic is not a subtype of type List<dynamic>。
在我执行的第一个 API 调用中,我通常会返回一个对象数组,但是,当它为空时,第二个 API 调用会返回一个我想推入名为 returnMovies 的数组中的对象列表,我该如何实现这个??有没有办法将这些对象推送到数组中??那么我想使用这个数组来动态构建一个 Listview.builder。我声明的方式是否正确?我对 Dart 很陌生。谢谢
我有一个类似下面的函数,其中线程通过使用std :: lock_guard互斥锁获取锁并通过ofstream写入文件.
当当前文件大小增加最大大小时,我创建一个压缩文件的独立线程并终止.
如果日志文件很大(比如说~500MB),压缩大约需要25秒以上.我分离压缩线程,因为没有其他线程(或主要)想要等待此线程完成.
但我需要知道压缩线程在执行以下行之前没有运行:
_compress_thread(compress_log, _logfile).detach();
Run Code Online (Sandbox Code Playgroud)
示例代码段:
void log (std::string message)
{
// Lock using mutex
std::lock_guard<std::mutex> lck(mtx);
_outputFile << message << std::endl;
_outputFile.flush();
_sequence_number++;
_curr_file_size = _outputFile.tellp();
if (_curr_file_size >= max_size) {
// Code to close the file stream, rename the file, and reopen
...
// Create an independent thread to compress the file since
// it takes some time to compress huge files.
if (the_compress_thread_is_not_already_running) //pseudo code
{
_compress_thread(compress_log, _logfile).detach();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在上述if条件下,即 …
我在一个有角度的网络应用程序中使用赛普拉斯进行e2e测试.当柏树第一次打开时,它会进入http://localhost:54401/__/#tests/integration/login.spec.ts
这显示了屏幕左侧的柏树测试基座和右侧的网络输出.一旦我的beforeEach函数调用cy.visit(),而不是更改输出,屏幕顶部的主URL将更改为:
http://localhost:4200/__/#tests/integration/login.spec.ts
然后Angular接管,它找不到__路由,所以相反页面被重定向到我的默认页面,我失去了Cypress dock/test runner.
赛普拉斯应该只是更改我的应用程序加载的框架,而不是页面URL.正在发生的事情导致赛普拉斯操纵主浏览器网址而不是帧网址.
如何解决这个问题,以便cypress定位框架而不是主浏览器窗口?这在过去有效,最近才开始起作用.我不确定它是否是柏树或铬问题.我想这可能是与柏网络安全的问题,所以我也尝试设置chromeWebSecurity: false在cypress.json无济于事.
https://docs.cypress.io/guides/guides/web-security.html#Disabling-Web-Security
我正在使用cypress 3.1.5.
我正在研究 React Native,我对此很陌生。我正在尝试显示文本,但是,它显示在文本的 android 结尾......而不是显示完整的文本。它只发生在android中,在iOS中运行良好。
我写了以下代码
<Text
numberOfLines={1}
adjustsFontSizeToFit
minimumFontScale={0.1}
style={labelStyle} //labelStyle nothing I have written
></Text>
Run Code Online (Sandbox Code Playgroud)
谁能建议我,我在代码中做错了什么?
是否有可能将参数传递给通过 getopt::long 调用的子程序?例如,当用户在命令行上指定script.pl -pandora 参数时,我有此代码调用 &Salt
GetOptions ( "domain=s" => \$domain,
"pandora=s" => \&Salt,
"reverse=s" => \$reverse,
"help" => \&Usage)
or die(&Usage);
Run Code Online (Sandbox Code Playgroud)
我如何获得要传递给 Salt 的参数?尝试了一些事情,例如:
GetOptions ( "domain=s" => \$domain,
"pandora=s" => \&Salt($pandora),
"reverse=s" => \$reverse,
"help" => \&Usage)
or die(&Usage);
Run Code Online (Sandbox Code Playgroud)
甚至
GetOptions ( "domain=s" => \$domain,
"pandora=s" => \&Salt($_[1]),
"reverse=s" => \$reverse,
"help" => \&Usage)
or die(&Usage);
Run Code Online (Sandbox Code Playgroud)
但它不会工作
我知道我可以通过做 => $pandora 来让它工作,然后在代码中使用一个条件 if ($pandora) { &Salt($pandora) } 但我会发现将 sub 直接放在 getOptions 中会更好,如果可能的
谢谢
我有一个多个数据帧的列表,每个数据帧包含一串日期,对于每个日期,+1表示增加或-1表示减少.
这是一个例子
security1 <- data.frame(
date = seq(from =as.Date('2019-01-01'), to = as.Date('2019-01-10'), by = 'day'),
direction = c(1, 1, 1, -1, -1, 1, 1, 1, 1, -1))
security2 <- data.frame(
date = seq(from =as.Date('2019-01-01'), to = as.Date('2019-01-10'), by = 'day'),
direction = c(1, -1, 1, -1, -1, 1, 1,- 1, 1, -1))
clcn <- list(Sec1 = security1, Sec2 = security2)
Run Code Online (Sandbox Code Playgroud)
对于每个数据帧,我试图找到最近一串更改的长度,以及上次数字大于此时的长度.如果前一天的移动是另一个方向,那么目前的连胜可能只是1天.
我已经搜索了几天的答案,并在数据框中的Compute计数变量中找到了以下使用序列和rle的单个数据帧
sequence(rle(as.character(data$list))$lengths)
Run Code Online (Sandbox Code Playgroud)
但我正在努力将其提供给lapply或map以使其迭代列表.
我不介意确切的输出,但理想情况下它包括:数据帧名称,当前条纹,前一个条纹更长,以及条纹结束的日期.但在最基本的情况下,只需将序列号添加为数据框中的新列将是一个巨大的帮助,我可以(尝试)从那里获取它.
考虑以下代码:
#include <stdio.h>
int main()
{
struct test {
int i;
int t;
};
struct test hello = (struct test) {
.i = 0,
.t = 1
};
printf("%d, %d\n", hello.i, hello.t);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
0, 1
Run Code Online (Sandbox Code Playgroud)
我的问题是这条线(struct test) {.i = 0, .t = 1 }在做什么?
它是否在输入一个代码块来输入struct test?甚至可能吗?
如果没有请告诉我它在做什么,谢谢.
我正在尝试为该模块创建手动模拟@material-ui/core/styles,该模块导出名为withStyles.
使用内联模拟可以jest.mock完美地工作,但是当我尝试将此逻辑移动到可共享__mocks__文件夹中时,它不再工作。
我从正在测试的文件中删除了所有不必要的代码,只保留产生问题的两行:
import { withStyles } from '@material-ui/core/styles';
console.log('loaded styles:', withStyles);
export default 'hello';
Run Code Online (Sandbox Code Playgroud)
测试也简化了,只是为了看看模拟是否正常工作,如下所示:
import test from '../test';
console.log(test);
Run Code Online (Sandbox Code Playgroud)
__mocks__我尝试的是在项目的根目录中创建一个文件夹,其中有该node_modules文件夹。
在那里我创建了第一个名为 的文件夹@material-ui,并在其中创建了另一个名为 的文件夹core。styles.js在这个文件夹中,我有一个使用以下代码调用的文件:
export const withStyles = 'hello world';
Run Code Online (Sandbox Code Playgroud)
所以结构看起来像:
- __mocks__
- @material-ui
- core
- styles.js
- node_modules
Run Code Online (Sandbox Code Playgroud)
这是有效的代码,在同一测试文件中定义了模拟:
jest.mock('@material-ui/core/styles', () => ({
withStyles: () => Component => props => (
<Component
classes=""
{...props}
/>
),
}));
Run Code Online (Sandbox Code Playgroud)
该文件夹发生的情况__mocks__ …