小编Pie*_*NAY的帖子

SequenceEqual不在父类型中调用Equals

父类型:

public class IdObject : IComparable<IdObject>, IEquatable<IdObject>
{
    public int id { get; set; }

    public bool Equals(IdObject other)
    {
        if (other == null) return this == null;
        if (this == null) return false;
        var test = other.id.CompareTo(this.id);

        return other.id.CompareTo(this.id) == 0;
    }

    public int CompareTo(IdObject other)
    {
        return other.id.CompareTo(this.id);
    }
}
Run Code Online (Sandbox Code Playgroud)

一个孩子:

public class NamedObject : IdObject
{
    public string name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

比较IdObjects的列表

var list1 = new List<IdObject>()
{
    new IdObject() { id …
Run Code Online (Sandbox Code Playgroud)

c# comparison

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

作曲家告诉错误的PHP版本

我知道很多人都在努力进入"使用错误的php版本的作曲家",而解决方案是将编曲者称为好作者(目前建议重复).

这是我的情况:

$ php -v
PHP 5.6.31 (cli) (built: Sep  8 2017 04:36:13) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

$ php /usr/local/bin/composer update
  Problem 1
    - This package requires php >=5.6.31 but your PHP version (5.5.9)
      does not satisfy that requirement.
Run Code Online (Sandbox Code Playgroud)

怎么解释这个?


有关信息,我正在使用官方php:5.6-fpm码头图像.我安装composer了:

$ curl -sS https://getcomposer.org/installer
  | php -- --install-dir=/usr/local/bin --filename=composer
Run Code Online (Sandbox Code Playgroud)

php composer-php docker

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

Vue Router 在启动时加载我所有的延迟加载组件

我有一个 Vue(vue:2.6 和 cli-service:4.1)应用程序,其延迟加载路由器配置如下:

路由器.ts

const Grid = () => import(/* webpackChunkName: "grid" */ './views/grid/Grid.vue');
const Calendar = () => import(/* webpackChunkName: "calendar" */ './views/calendar/Calendar.vue');
const Tree = () => import(/* webpackChunkName: "tree" */ './views/tree/Tree.vue');

const routes = [
    { path: '/', component: Grid, name: 'grid' },
    { path: '/calendar', component: Calendar, name: 'calendar' },
    { path: '/tree', component: Tree, name: 'tree' },
];

export const router = new VueRouter({ routes });
Run Code Online (Sandbox Code Playgroud)

我正在使用 Babel,所以我按照文档中的建议使用动态导入插件

babel.config.js

module.exports = { …
Run Code Online (Sandbox Code Playgroud)

javascript webpack vue.js babeljs

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

Python - 单词出现次数

我正在尝试执行一个函数,允许查找文本中(整个)单词(不区分大小写)的出现次数.

示例:

>>> text = """Antoine is my name and I like python.
Oh ! your name is antoine? And you like Python!
Yes is is true, I like PYTHON
and his name__ is John O'connor"""

assert( 2 == Occs("Antoine", text) )
assert( 2 == Occs("ANTOINE", text) )
assert( 0 == Occs("antoin", text) )
assert( 1 == Occs("true", text) )    
assert( 0 == Occs("connor", text) )
assert( 1 == Occs("you like Python", text) )
assert( 1 == Occs("Name", text) ) …
Run Code Online (Sandbox Code Playgroud)

python python-2.3

0
推荐指数
1
解决办法
5447
查看次数

每个和$ .post的闭包

我有一个我想要编辑的项目列表

<form id="mainForm" action="machin_chose">
    <div><input name="field" value="chouchouette" /></div>
    <div class="modified><input name="field" value="trutruc" /></div>
    <div class="modified"><input name="field" value="machin" /></div>
</form>
Run Code Online (Sandbox Code Playgroud)

并在每个修改的项目上发布ajax帖子

$('#mainForm div.modified').each(function () {
    item = $(this);
    $.post(
        $('#mainForm').attr('action')
      , $(this).find(':input').serialize()
      , function (data) {
            item.removeClass('modified');
        }
    });
};
Run Code Online (Sandbox Code Playgroud)

成功发布的项目应该被删除他们的modified课程.
我试图使用一个闭包item来保持当前修改过的闭包.
但由于它是异步的,因此item总是包含最后一个修改过的.

如何在成功处理程序中检索当前发布的项目?

javascript ajax jquery closures

0
推荐指数
1
解决办法
80
查看次数