http://jsfiddle.net/chovy/dk5Ua/
<div></div>
var $span = $('<span>foo</span>');
$span.hide();
$("div").append($span);
$span.fadeIn();
Run Code Online (Sandbox Code Playgroud)
您会注意到生成的跨度具有内联样式display: block;
而不是内联样式.
这是由此产生的html:
<span style="display: block;">foo</span>
Run Code Online (Sandbox Code Playgroud)
如何让fadeIn()得到显示:inline?
我在运行测试时在save()方法中遇到错误.
var User = require('../../models/user')
, should = require('should');
describe('User', function(){
describe('#save()', function(){
it('should save without error', function(done){
var user = new User({
username : 'User1'
, email : 'user1@example.com'
, password : 'foo'
});
user.save(function(err, user){
if (err) throw err;
it('should have a username', function(done){
user.should.have.property('username', 'User1');
done();
});
});
})
})
})
Run Code Online (Sandbox Code Playgroud)
这是错误:
$ mocha test/unit/user.js
?
? 1 of 1 test failed:
1) User #save() should save without error:
Error: timeout of 2000ms exceeded
at Object.<anonymous> (/usr/local/lib/node_modules/mocha/lib/runnable.js:1 …
Run Code Online (Sandbox Code Playgroud) var FilterList = React.createClass({
remove: function(item){
this.props.items = this.props.items.filter(function(itm){
return item.id !== itm.id;
});
return false;
},
render: function() {
var createItem = function(item) {
return (
<li>
<span>{item}</span>
<a href data-id="{item.id}" class="remove-filter" onClick={this.remove.bind(item)}>remove</a>
</li>
);
};
return <ul>{this.props.items.map(createItem.bind(this))}</ul>;
}
});
var FilterApp = React.createClass({
getInitialState: function() {
return {items: [], item: {
id: 0,
type: null
}};
},
onChangeType: function(e){
this.setState({
item: {
id: this.state.items[this.state.items.length],
type: e.target.value
}
});
},
handleSubmit: function(e) {
e.preventDefault();
var nextItems = this.state.items.concat([this.state.item]);
var …
Run Code Online (Sandbox Code Playgroud) 的package.json
"moduleNameMapper": {
"i18next": "<rootDir>/__mocks__/i18nextMock.js"
}
Run Code Online (Sandbox Code Playgroud)
i18n.js
import i18n from 'i18next'
import XHR from 'i18next-xhr-backend'
// import Cache from 'i18next-localstorage-cache'
import LanguageDetector from 'i18next-browser-languagedetector'
i18n
.use(XHR)
// .use(Cache)
.use(LanguageDetector)
.init({
fallbackLng: 'en',
// wait: true, // globally set to wait for loaded translations in translate hoc
lowerCaseLng: true,
load: 'languageOnly',
// have a common namespace used around the full app
ns: ['common'],
defaultNS: 'common',
debug: true,
// cache: {
// enabled: true
// },
interpolation: {
escapeValue: false, // not …
Run Code Online (Sandbox Code Playgroud) 我需要不同的./routes/login
页面布局...我试图忽略主./routes/__layout.svelte
文件,因为我不需要侧边栏。
<script>
import NavBar from '../components/NavBar.svelte';
</script>
<main>
{#if segment === 'login'}
<section>
<slot />
</section>
{:else}
<NavBar />
<section>
<slot />
</section>
{/if}
</main>
<style>
main {
display: flex;
justify-content: flex-start;
}
section {
padding: 2.4rem;
width: 100%;
background-color: #f2f6fa;
}
</style>
Run Code Online (Sandbox Code Playgroud)
我收到一个错误segment is not defined
。
我正在尝试使用WebStorm编辑器(目前使用的是vim).
而且我注意到我无法分辨出行尾的位置,因为您可以在代码编辑器中将光标移动到行尾.
我发现这非常令人沮丧.我用来能够确定线的末端在vi的哪个位置.
当我到达一行并向右移动时,有没有办法强制光标转到下一行?
我在使用node-webkit的简单示例中遇到以下错误:
Uncaught AssertionError: path must be a string
Run Code Online (Sandbox Code Playgroud)
的index.html
//base.js
require(["test"], function(test) {
test.init();
});
//test.js
define(function(){
window.c = window.console;
return {
init: function(){
c.log('test.init');
},
destroy: function(){
c.log('test.destroy');
}
}
});
Run Code Online (Sandbox Code Playgroud) 是否可以删除或禁用HTML注释角度生成?
<ol class="items">
<!-- ngRepeat: item in list | orderBy:'time':true -->
</ol>
Run Code Online (Sandbox Code Playgroud)
它打破了使用:empty
伪类的CSS规则.
ol:empty {
content: "No results";
}
Run Code Online (Sandbox Code Playgroud)
为了应用规则,不需要空格或注释:
<ol></ol>
Run Code Online (Sandbox Code Playgroud) 我正在将该类ng-animate
应用于该指令,但我没有得到:
ng-hide-remove.ng-hide-remove-active
要么 .ng-hide-remove.ng-hide-remove-active
我有角度和角度 - 动画1.3加载.并且包含ngAnimate
在app.js中
<div class="message animate-show {{message.type}}" ng-show="message">
{{message.text}}
</div>
Run Code Online (Sandbox Code Playgroud)
转换没有发生:
.message.animate-show {
line-height:20px;
opacity:1;
padding:10px;
&.ng-hide-add.ng-hide-add-active,
&.ng-hide-remove.ng-hide-remove-active {
-webkit-transition:all linear 0.5s;
transition:all linear 0.5s;
}
&.ng-hide {
line-height:0;
opacity:0;
padding:0 10px;
}
}
Run Code Online (Sandbox Code Playgroud) 我正试图通过业力单元测试chai-as-promised
来处理$q
承诺.
svc.test = function(foo){
if (!foo){
// return Promise.reject(new Error('foo is required'));
return $q.reject(new Error('foo is required'));
} else {
// get data via ajax here
return $q.resolve({});
}
};
it.only('should error on no foo', function(){
var resolvedValue = MyServices.test();
$rootScope.$apply();
return resolvedValue.should.eventually.be.rejectedWith(TypeError, 'foo is required');
});
Run Code Online (Sandbox Code Playgroud)
单元测试只是超时了.我不确定我在这里做错了什么来得到正确解决的承诺.这似乎是一个使用问题$q
- 当我使用原生Promise.reject()
它工作正常.
我在这里提交了一张票,但似乎没有人回应:https: //github.com/domenic/chai-as-promised/issues/150
angularjs ×3
css ×2
javascript ×2
reactjs ×2
chai ×1
i18next ×1
jestjs ×1
jquery ×1
karma-runner ×1
mocha.js ×1
mongoose ×1
ng-animate ×1
node-webkit ×1
node.js ×1
requirejs ×1
sveltekit ×1
unit-testing ×1
webstorm ×1