小编cho*_*ovy的帖子

jQuery fadeIn()导致display:block为内联元素

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?

css jquery

8
推荐指数
2
解决办法
1万
查看次数

我如何使用mocha和mongoose?

我在运行测试时在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)

unit-testing mocha.js mongoose node.js

8
推荐指数
1
解决办法
3764
查看次数

how to remove an item from a list with a click event in ReactJS?

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)

javascript reactjs

8
推荐指数
1
解决办法
2万
查看次数

我如何在开玩笑中模拟react-i18next和i18n.js?

的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)

i18next reactjs jestjs react-i18next

8
推荐指数
4
解决办法
7270
查看次数

如何忽略 svelte-kit 中的默认布局?

我需要不同的./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

sveltekit

8
推荐指数
2
解决办法
9668
查看次数

如何在WebStorm中停止行尾

我正在尝试使用WebStorm编辑器(目前使用的是vim).

而且我注意到我无法分辨出行尾的位置,因为您可以在代码编辑器中将光标移动到行尾.

我发现这非常令人沮丧.我用来能够确定线的末端在vi的哪个位置.

当我到达一行并向右移动时,有没有办法强制光标转到下一行?

webstorm

7
推荐指数
2
解决办法
1992
查看次数

未捕获的AssertionError:路径必须是Require.js中的字符串错误

我在使用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)

javascript requirejs node-webkit

7
推荐指数
1
解决办法
6507
查看次数

从html中删除角度注释

是否可以删除或禁用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)

css angularjs

7
推荐指数
1
解决办法
2058
查看次数

ng-animate在1.3中不起作用

我正在将该类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)

angularjs ng-animate

7
推荐指数
1
解决办法
1万
查看次数

chai-as-promise测试不适用于$ q承诺

我正试图通过业力单元测试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 chai karma-runner chai-as-promised

7
推荐指数
1
解决办法
1372
查看次数