我今天被问到这个问题:
如何将项目添加到列表并返回该列表?
List<T>.Add(T)返回的代码为void.所以你不能做这样的事情:
var list = new List<string>{"item1","item2"};
var newList = list.Add("item3");
Run Code Online (Sandbox Code Playgroud)
这与使用AutoMapper有关,尽管该部分并不是特别重要.
我正在为我们的项目设置测试运行器任务,但遇到了一些意外的情况。我们的任务没有使用以下模式获取任何文件:
'/tests/**/*.spec.js'
Run Code Online (Sandbox Code Playgroud)
我们的目录结构是这样的:
--Scripts
--app
--tests
-test.spec.js
-gulp.js
-karma.conf.js
etc.
Run Code Online (Sandbox Code Playgroud)
然而,这是提出了 0 个测试用例。当我将模式更改为:
'/tests/*.spec.js'
Run Code Online (Sandbox Code Playgroud)
然后它就会按预期工作。现在,我知道这/**/*spec.js是“零个或多个子目录中以“spec.js”结尾的文件”的模式。但是,感觉应该有一个简单的模式来表示“此目录和零个或多个子目录中以“spec.js”结尾的所有文件”。否则,如果我的结构如下所示,我知道必须使用这两种模式:
--Scripts
--app
--tests
-test.spec.js
--subTests
-test2.spec.js
-gulp.js
-karma.conf.js
etc.
Run Code Online (Sandbox Code Playgroud)
上面的内容需要我的 gulp 任务如下所示:
gulp.task('unit-test', ['lint'], function (done) {
gulputil.log('Running unit tests...');
//return gulp.src(testFilesDirect).pipe(jasmine({ verbose: true, includeStackTrace: true }));
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
files: ['/tests/*.spec.js', '/tests/**/*.spec.js'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
}, done).start();
});
Run Code Online (Sandbox Code Playgroud)
这是正确的还是我错过了一些不需要两个测试模式的基本内容?
这里还有另一篇文章讨论符号链接:Gulp - Target all files …
我已经将 Vuetify (v1.5.16) 与 VueJS 一起使用有一段时间了,并且需要利用v-calendar组件,但我遇到了点击事件的问题。
简而言之,我希望允许用户单击月视图中日历上的空白区域来打开一个对话框来添加事件。我还希望用户单击事件槽并能够查看该事件的详细信息并将其删除。
我的问题在于,如果我在 v-calendar 组件上设置 @click:day="someMethod" ,那么当单击当天的空白以及单击事件槽时,它将触发该事件。
问题示例:codepen
<v-calendar
:now="today"
:value="today"
color="primary"
:type="selectedType"
@click:day="(event)=>dateClick(event,true)"
>
<template v-slot:day="{ date }">
<template v-for="event in eventsMap[date]">
<v-menu
:key="event.title"
v-model="event.open"
full-width
offset-x
>
<template v-slot:activator="{ on }">
<div
v-if="!event.time"
v-ripple
class="my-event"
v-on="on"
v-html="event.title"
></div>
</template>
<v-card
color="grey lighten-4"
min-width="350px"
flat
>
<v-toolbar
color="primary"
dark
>
<v-btn icon>
<v-icon>edit</v-icon>
</v-btn>
<v-toolbar-title v-html="event.title"></v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>favorite</v-icon>
</v-btn>
<v-btn icon>
<v-icon>more_vert</v-icon>
</v-btn>
</v-toolbar>
<v-card-title primary-title>
<span v-html="event.details"></span>
</v-card-title> …Run Code Online (Sandbox Code Playgroud) 这是jQuery的警报代码undefined.
我需要在变量中传递actual_price或base_price,当我传递它时,它会给出所需的结果:
parsed.test[indx].base_price
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我如何使用变量?提前致谢
例
var data = '{"test":[
{"base_price" : "10"},
{"actual_price" : "20"}
]
}';
var parsed = JSON.parse(data);
var indx = 1;
var str = 'actual_price';
alert(parsed.test[indx].str);
Run Code Online (Sandbox Code Playgroud)