我一直在通过一个简单的hello world示例来阅读react.js教程.我找不到以下不应该工作的原因,但我不断收到此错误.
Uncaught Error: Invariant Violation: React.render(): Invalid component element.
Run Code Online (Sandbox Code Playgroud)
我有以下代码.它似乎可以工作,如果我做React.createElement,但不适用于JSX元素.
<!doctype html>
<html>
<head>
<script src="https://fb.me/react-0.13.3.js"></script>
<script src="https://fb.me/JSXTransformer-0.13.3.js"></script>
<script type="text/jsx">
document.body.onload = function(){
console.log("shuff")
var HelloWorld = React.createClass({
render: function(){
return <div>Hello, Ian Shuff!</div>;
}
});
React.render( new HelloWorld(), document.getElementById("test"))
}
</script>
</head>
<body>
<div id="test"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我运行时运行以下文件node test.js.
var Jasmine = require('jasmine');
var jasmine = new Jasmine();
var request = require('request');
describe("test", function(){
it("works", function(){
expect(5 + 2).toEqual(4);
});
it("should respond with hello world", function(done){
request('http://localhost:3000/', function(err, res, body){
expect(body).toEqual('hello world');
done();
})
});
})
jasmine.execute();
Run Code Online (Sandbox Code Playgroud)
这给了我以下输出:
Started
F.
Failures:
1) test works
Message:
Expected 7 to equal 4.
Stack:
Error: Expected 7 to equal 4.
at Object.<anonymous>
2 specs, 1 failure
Finished in 0.037 seconds
Run Code Online (Sandbox Code Playgroud)
显然,一个失败,显示F,一个通过,显示点.我是否可以更改此配置以使其显示通过和失败的测试?
我正在尝试从ELM中的简单数组构建元素列表.预期的结果实际上只是一个元素列表,其中1作为第一项,2作为第二项,依此类推.
import Html exposing (..)
import Html.Attributes exposing (class, id)
import List exposing (map)
theArray = [1,2,3,4,5,6]
createListItem item =
li [] [ text (toString item)]
buildList collection =
map createListItem collection
builtList = ul [] [(buildList theArray)]
main =
builtList
Run Code Online (Sandbox Code Playgroud)
但我一直在第13行得到编译器错误.我尝试过将地图元素注释为html,但我看不出应该怎么做.
The 2nd argument to function `ul` is causing a mismatch.
*13| builtList = ul [] [(buildList theArray)]*
Function `ul` is expecting the 2nd argument to be:
List VirtualDom.Node
But it is:
List (List Html)
Run Code Online (Sandbox Code Playgroud) 我用谷歌搜索了这个,但我找不到任何具体的解决方案.基本上我有一个依赖于init调用的vue组件,我希望它在调用完成之前停止渲染,此时我希望组件呈现.看似简单,但除非我遗漏了一些东西,否则找不到任何生命周期方法.
我有角度的以下代码.
<img class="img-circle image-stroke" ng-src="{{person.photo}}" onerror="this.src='http://www.clker.com/cliparts/5/9/4/c/12198090531909861341man%20silhouette.svg.hi.png'"></img>
Run Code Online (Sandbox Code Playgroud)
我从数据库中获取一个人物对象photo,其中包含该人物照片的网址.问题是,有时这个值将为null.正如您所看到的,我已使用onerrror标记中的属性处理它,因此每当它为null并ng-src抛出错误时,它将回退到默认图像.
问题是,它仍然会在控制台中抛出以下错误.
GET http://localhost:3000/module/seasons/person.photo 404 (Not Found)
有没有办法压制这个错误?在制作中,很可能会有12或13个人一次没有照片值,我不希望我的老板在控制台中看到12或13个错误,即使实际网站上没有任何内容.
我的应用程序中有一个人名的搜索框.候选人的姓名存储为firstName,然后存储为lastName.当我搜索应用程序时,应用程序输入提交对ajax函数的调用,其中我有这段代码.
filters.where = {
$or: ['firstName', 'lastName', 'email'].map((item) =>
({[item]: {[queryClause]: `%${query}%`}}))
};
const scope = req.query.list;
const candidates = await CandidateModel.scope(scope).findAll(filters);
Run Code Online (Sandbox Code Playgroud)
因此,如果我输入搜索框"John",它将找到候选人,如果我输入单词"Smith",它将找到候选人.
问题是,如果我输入全名"John Smith",它将不会出现,因为查询正在检查"John Smith"是否等于"John",即名字,或"John Smith"等于"史密斯",姓氏.它不等于这些中的任何一个.
有没有办法通过sequalize中的组合字段进行过滤,因此它会测试查询是否与firstName和lastName字段组合在一起?