我正在尝试在我的应用程序中创建无限滚动功能,但感觉有点抽象.我想使用ui-scroll,这个小提琴显示了它如何工作的简单示例.
我已经阅读了自述文件,并查看了一些示例,我已将示例集成到我的项目中并使其正常工作,但我无法弄清楚如何将其与我自己的数据库中的数据相结合.
我有一个名为电影的数据库表.该电影有诸如几个值title,release_date,image_url
我如何将数据插入到$scope.movieDataSource我的视图中我可以使用它?
$http.get(('/movies.json'), {
cache: true
})
.success(function(data, status, headers, config) {
if (status == 200) {
$scope.userMovies = data;
} else {
console.error('Error happened while getting the user list.')
}
$scope.movieDataSource = {
get: function(index, count, callback) {
var i, items = [$scope.userMovies], item;
var min = 1;
var max = 1000;
for (i = index; i < index + count; i++) {
if (i < …Run Code Online (Sandbox Code Playgroud) 当我运行以下代码时:
if df.loc[df['state_code'].isin(['12','09'])]:
Run Code Online (Sandbox Code Playgroud)
它给出了这个错误:
ValueError:系列的真值不明确。
使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()
这里有什么问题吗?
在我的Angular项目中,我试图BehaviorSubject用一个空数组初始化属性:
export class Buffer {
$items: BehaviorSubject<Array<Item>>; // or <Item[]>
private _items: Array<Item>; // or Item[]
constructor(settings: Settings) {
this.$items = new BehaviorSubject([]);
}
}
Run Code Online (Sandbox Code Playgroud)
打字稿编译器抛出以下错误:
错误TS2322:类型'
BehaviorSubject<never[]>'不能分配给类型'BehaviorSubject<Item[]>'
我尝试阅读有关“从不”类型的信息,但我不明白为什么会收到这样的错误。另外,如果我将$items实例化替换为,this.$items = new BehaviorSubject(new Array())则不会有错误。但是在这种情况下,我的IDE会警告我:“可以简化数组实例化”。
有什么问题,我应该在这里做什么?我正在使用打字稿2.7.2。
我刚开始使用 Vue.js 和 Vue CLI,我遇到了一个问题,我不明白为什么我不能从范围动态设置图像,但我可以直接在 HTML obj.img 中编写它也是一个有@/assets/logo.png值的字符串。我假装 ajax 调用超时,但浏览器无法正确解析图像的路由。
<div slot="media">
<img :src="obj.img"> <!-- http://localhost:8080/@/assets/logo.png -->
<img src="@/assets/logo.png"> <!-- http://localhost:8080/img/logo.82b9c7a5.png -->
</div>
Run Code Online (Sandbox Code Playgroud)
另外,为什么路线不同?有任何想法吗?
我有这样的数组,
[[{"user":"1","nice":"0","sys":"1","CPU":"93","irq":"0"},
{"user":"1","nice":"0","sys":"1","CPU":"92","irq":"0"},
{"user":"1","nice":"0","sys":"1","CPU":"92","irq":"0"},
{"user":"1","nice":"0","sys":"1","CPU":"92","irq":"0"}],
[{"user":"0","nice":"0","sys":"0","CPU":"91","irq":"0"},
{"user":"0","nice":"0","sys":"1","CPU":"91","irq":"0"},
{"user":"1","nice":"0","sys":"0","CPU":"91","irq":"0"},
{"user":"0","nice":"0","sys":"0","CPU":"90","irq":"0"}]]
Run Code Online (Sandbox Code Playgroud)
我想使用 ngFor 循环遍历 HTML 表中的这个对象数组
<table class="table table-striped mt-5">
<thead>
<tr>
<th scope="col">User</th>
<th scope="col">Nice</th>
<th scope="col">Sys</th>
<th scope="col">CPU</th>
<th scope="col">IRQ</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let post of posts">
<td>{{post.user}}</td>
<td>{{post.nice}}</td>
<td>{{post.sys}}</td>
<td>{{post.CPU}}</td>
<td>{{post.irq}}</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
但我的代码不起作用
尝试检查属性是否存在并且它不是空字符串。
我可以让这个测试正常工作:
it('the data includes a list of items', function(done){
body.should.have.property('items').and.to.be.an('array');
done();
});
Run Code Online (Sandbox Code Playgroud)
但在下面,当我尝试检查项目数组中存在的属性时,我无法让它工作:
it('each item should include properties \'label\' and \'url\'', function(done){
body['items'].should.have.property('label').and.to.be.a('string');
body['items'].should.have.property('url').and.to.be.a('string');
done();
});
Run Code Online (Sandbox Code Playgroud)
但我收到错误 AssertionError:expected [ Array(3) ] to have a property 'label'
返回的 JSON 对象如下所示:
{
"items": [
{
"label": "Item 1",
"url": "http://www.something.com"
},
{
"label": "Item 2",
"url": "http://www.something.com"
},
{
"label": "Item 3",
"url": "http://www.something.com"
}
]
}
Run Code Online (Sandbox Code Playgroud) 我在这里有这个小问题:
events.js:200
引发新错误.ERR_INVALID_ARG_TYPE('listener','Function',listener);
^
TypeError [ERR_INVALID_ARG_TYPE]:“侦听器”参数必须为Function类型。 在Object的 Client.addListener(events.js:259:10)的
_addListener(events.js:200:11)
处接收到的类型未定义
。(D:\ Yoshio \ index.js:7:5)
在Module._compile(内部/模块/cjs/loader.js:689:30)
在Object.Module._extensions..js(内部/模块/ cjs / loader)的.js:700:10)
在Module.load(内部/模块/ CJS / loader.js:599:32)
在tryModuleLoad(内部/模块/ CJS / loader.js:538:12)
在Function.Module._load(内部/模块/cjs/loader.js:530:3)
在启动时在Function.Module.runMain(内部/模块/cjs/loader.js:742:12)
(内部/bootstrap/node.js:266:19 )
我搜索了答案,但找不到任何答案,请告诉我该怎么做。
这是我的代码:
const Discord = require("discord.js");
const TOKEN = "mytoken";
var bot = new Discord.Client();
bot.on("message"), function(message) {
console.log(message.content);
};
bot.login(TOKEN);
Run Code Online (Sandbox Code Playgroud) 我认为答案是否定的,除了删除对包含对象的所有引用并允许垃圾收集最终删除包含对象的所有内容。
实时示例(使用控制台查看日志输出(在 Chrome 中按 F12 等))
代码:
(function () {
var nameValue = "uninitialized";
Object.defineProperty(this, "name", {
enumerable: true,
configurable: false,
get: function () {
return nameValue;
},
set: function () {
console.log("This is a read-only property");
}
});
console.log(nameValue);
nameValue = "George";
delete this.name;
this.name = "";
console.log(this.name);
})();
Run Code Online (Sandbox Code Playgroud) 我正在使用这个:http://angular-ui.github.io/ui-utils/,更具体一点:https://github.com/angular-ui/ui-utils/blob/master/modules/滚动/ README.md
但它似乎没有用.这是一个例子:
<div ng-scroll-viewport style="height:240px;" class="chat-messages">
<div class="chat-message" ng-scroll="chat in chats">
<div ng-class="$index % 2 == 0? 'sender pull-right' : 'sender pull-left'">
<div class="icon">
<img src="{{chat.img}}" class="img-circle" alt="">
</div>
<div class="time">
{{chat.time}}
</div>
</div>
<div ng-class="$index % 2 == 0? 'chat-message-body on-left' : 'chat-message-body'">
<span class="arrow"></span>
<div class="sender"><a href="#">{{chat.name}}</a></div>
<div class="text">
{{chat.msg}}
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
但我得到的HTML是这样的:
<div class="chat">
<div class="chat-messages" style="height:240px;" ng-scroll-viewport="">
<!--
ngScroll: chat in chats
-->
</div>
Run Code Online (Sandbox Code Playgroud)
如果我用ng-repeat替换ng-scroll,它可以很好地工作.但聊天需要滚动条,所以...我怎么能得到一个呢?:)
我想在删除项目*ngFor的*ngFor.
当我删除回复'test2'时,
在我添加了另一个回复之后,'test3'变空了.
<hello name="{{ name }}"></hello>
<form #form="ngForm" (ngSubmit)="submit()" ngNativeValidate class="mt-4">
<div *ngFor="let content of contents; let indexContent = index; let firstContent = first;">
<div *ngFor="let message of content.messages; let indexMessage = index; let firstMessage = first;">
<table>
<thead>
<tr>
<th>Id</th>
<th>Text</th>
<th class="text-right">Action</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let reply of message.replies; let indexReply = index; let firstReply = first;">
<td [innerHtml]='reply.id'></td>
<td>
<input type="text"
id="{{indexContent}}-{{indexMessage}}-{{indexReply}}-reply-text"
[(ngModel)]=content.messages[indexMessage].replies[indexReply].text
name="[[indexContent]]-[{{indexMessage}}]-[{{indexReply}}]-reply-text">
<br>
<span [innerHtml]="contents[indexContent].messages[0].replies[indexReply].text"></span>
</td>
<td>
<span (click)="message.removeReply(reply)">Remove …Run Code Online (Sandbox Code Playgroud) 我在js中有一个特定的对象数组,表示一个表的列.我的目标是:
var columns = {
"image": {
"show": false,
"orderable": true,
"value": 0,
"displayOrder":2
},
"name": {
"show": true,
"orderable": true,
"value": 1,
"displayOrder":0
},
"company": {
"show": false,
"orderable": false,
"value": 2,
"displayOrder":1
}
}
Run Code Online (Sandbox Code Playgroud)
我必须通过"displayOrder"来订购对象,但是使用类似的函数
columns.sort(function(a, b) {
return parseFloat(a.displayOrder) - parseFloat(b.displayOrder);
});
Run Code Online (Sandbox Code Playgroud)
显然它会返回一个错误.我怎么能这样做?
我正在使用带有express和ejs的nodejs.
互联网上的每一个人都会问如何将价值从节点传递到视图,但相反呢?
例如,我要求我的用户在表单中输入一个字符串,当用户单击该按钮时,如何获取该字符串而不将其作为url中的参数传递?
表格:
<div class="container">
<form style="width:50%">
<div class="form-group">
<label for="text">Name of the product</label>
<input type="text" class="form-control" id="pName">
</div>
<div class="form-group">
<label for="text">Reciever</label>
<input type="text" class="form-control" id="reciever">
</div>
<div class="form-group">
<label for="text">Location</label>
<input type="text" class="form-control" id="location">
</div>
<!-- <div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>-->
<button type="submit" class="btn btn-default">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
app.js
var express = require('express');
var app = express();
//ALL GLOBAL VARIABLES
var port = 8080;
app.get('/', function(req, res) {
res.render('index.ejs');
});
app.get('/barcode', function(req,res) {
res.render('barcode.ejs');
});
app.listen(port);
Run Code Online (Sandbox Code Playgroud)
我知道我可以这样做: …
javascript ×5
angular ×3
node.js ×3
angularjs ×2
typescript ×2
ui-scroll ×2
angular-ui ×1
chai ×1
datatables ×1
discord.js ×1
ejs ×1
express ×1
jquery ×1
mocha.js ×1
ngfor ×1
pandas ×1
python ×1
rxjs ×1
scrollbar ×1
sorting ×1
supertest ×1
vue-cli-3 ×1
vue.js ×1