小编Dam*_*ica的帖子

反应多个过滤器下拉菜单

我有React app,您可以根据几个不同的属性过滤列表.目前我可以一次过滤每个类别,但我想一次过滤多个类别,因此当您选择更多过滤器时,列表会不断变小.然后,当您清除所有值时,它将返回到原始列表.我怎样才能做到这一点?

演示

我的代码示例

getInitialState: function() {
  return {
    data: this.props.data,
    bender: '',
    nation: '',
    person: '',
    show: ''
  }
},
filterItems: function(val, type) {
   switch (type) {
    case 'bender':
      this.setState({bender: val});
      break;
    case 'nation':
      this.setState({nation: val});
      break;
    case 'person': 
      this.setState({person: val});
      break;
    case 'show':
      this.setState({show: val});
      break;
    default:
      break;
  }
  var filteredItems;
  if (val) {
    filteredItems = this.props.data.filter(function(item) {
      return item[type] === val;
    });
  } else {
    filteredItems = this.props.data;
  }
  this.setState({data: filteredItems});
}
Run Code Online (Sandbox Code Playgroud)

javascript filter reactjs

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

如何用PHP解析Wikipedia XML?

如何用PHP解析Wikipedia XML?我用simplepie尝试过,但我一无所获.这是我想要获取其数据的链接.

http://en.wikipedia.org/w/api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content&format=xml

编辑代码:

<?php
    define("EMAIL_ADDRESS", "youlichika@hotmail.com"); 
    $ch = curl_init(); 
    $cv = curl_version(); 
    $user_agent = "curl ${cv['version']} (${cv['host']}) libcurl/${cv['version']} ${cv['ssl_version']} zlib/${cv['libz_version']} <" . EMAIL_ADDRESS . ">"; 
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); 
    curl_setopt($ch, CURLOPT_ENCODING, "deflate, gzip, identity"); 
    curl_setopt($ch, CURLOPT_HEADER, FALSE); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    curl_setopt($ch, CURLOPT_HTTPGET, TRUE); 
    curl_setopt($ch, CURLOPT_URL, "http://en.wikipedia.org/w/api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content&format=xml"); 
    $xml = curl_exec($ch); 
    $xml_reader = new XMLReader(); 
    $xml_reader->xml($xml, "UTF-8"); 
    echo $xml->api->query->pages->page->rev;
?>
Run Code Online (Sandbox Code Playgroud)

php xml mediawiki wikipedia-api mediawiki-api

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

如何从维基百科API获取电影内容?

我试图从维基百科API获得电影"你的殿下"的描述,但它没有给我什么.

http://en.wikipedia.org/w/api.php?format=xml&action=query&titles=your%20highness&prop=revisions&rvprop=content

当我谷歌"你的殿下"维基百科显示为第三个结果时,那就是我希望API给我的页面.

此外,我只想要电影描述的文字,没有混合的维基语法或任何东西.

case-sensitive capitalization wikipedia-api

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

如何使用jQuery选择属性不透明度为1的元素

我有这些元素,我需要选择ul里面的li,其中opacity = 1.我怎样才能做到这一点?

<ul class="class" id="ul">
                <li style="width: 100%; list-style: none outside none; position: absolute; top: 0px; left: 0px; z-index: 98; opacity: 0;"><a title="title1" href=""><img alt="alt" class="class_name" src="/images/7dfc294d5c3bcebecb2ec0e44fd27d1c.jpg"></a></li>
                <li style="width: 100%; list-style: none outside none; position: absolute; top: 0px; left: 0px; z-index: 98; opacity: 0;"><a title="title2" href=""><img alt="alt" class="class_name " src="/images/a9c9eb42934df4576b352d88f607f292.jpg"></a></li>
                <li style="width: 100%; list-style: none outside none; position: absolute; top: 0px; left: 0px; z-index: 98; opacity: 0;"><a title="title3" href=""><img alt="alt" class="class_name " src="/images/b64264692c0d648068c9d1380e9099c1.jpg"></a></li>
                <li style="width: 100%; list-style: none outside …
Run Code Online (Sandbox Code Playgroud)

jquery attributes opacity

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

从现有数据库创建实体

最新版本Symfony2并在MAC上使用MAMP.以下命令:

php app/console doctrine:mapping:convert yml ./src/Acme/DemoBundle/Resources/config/doctrine/metadata/orm --from-database --force
Run Code Online (Sandbox Code Playgroud)

我的错误:

[Doctrine\DBAL\DBALException]                                                                    
  Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.
Run Code Online (Sandbox Code Playgroud)

不知道.怎么了?

与我的数据库的连接正在运行.因为我试图创建一个表,输出就是表存在.

orm doctrine symfony doctrine-orm

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

解释python模块itertools的组合功能

我经常itertools在Python中使用模块,但如果我不知道它背后的逻辑,那就像是作弊.

这是我的代码,当订单不重要时,找到字符串的组合.

def combinations(iterable, r):
    # combinations('ABCD', 2) --> AB AC AD BC BD CD
    # combinations(range(4), 3) --> 012 013 023 123
    pool = tuple(iterable)
    n = len(pool)
    if r > n:
        return
    indices = list(range(r))
    yield tuple(pool[i] for i in indices)
    while True:
        for i in reversed(range(r)):
            if indices[i] != i + n - r:
                break
        else:
            return
        indices[i] += 1
        for j in range(i+1, r):
            indices[j] = indices[j-1] + 1
        yield tuple(pool[i] for i in …
Run Code Online (Sandbox Code Playgroud)

python combinations python-itertools

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

文本区域中的 onkeyup 事件

我有一个非常基本的 HTML 输入/输出结构:

<textarea id="input" onkeyup="sendCode()">
Hello World!
</textarea> 

<div id="output"></div>
Run Code Online (Sandbox Code Playgroud)

我有 JS 函数,它应该传递从输入到输出的所有内容:

var input = document.getElementById("input");
var output = document.getElementById("output");

function sendCode(){
 output.innerHTML = input.innerHTML;
}
Run Code Online (Sandbox Code Playgroud)

当我手动调用该函数时,该sendCode()函数可以工作,但似乎该onkeyup事件未在此文本区域中触发。

这是jsfiddle: http: //jsfiddle.net/mudroljub/y5a2n8ab/

有什么帮助吗?

更新:jsfiddle 已更新并正在运行。

javascript textarea onkeyup dom-events

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

Three.js raycaster交叉口

我编写了下面的代码来获得与3d形状的交点.它运作良好,但如果有两个与形状的交点,它只返回最近的交点,而我需要与形状最近的交点.我怎样才能到达最近的十字路口?

  /*here I create a cube*/

            var geometry0 = new THREE.Geometry()
            geometry0.vertices = [new THREE.Vector3(0.5, -0.5, 0.5), new THREE.Vector3(-0.5, -0.5, 0.5), new THREE.Vector3(-0.5, -0.5, -0.5), new THREE.Vector3(0.5, -0.5, -0.5), new THREE.Vector3(0.5, 0.5, 0.5), new THREE.Vector3(-0.5, 0.5, 0.5), new THREE.Vector3(-0.5, 0.5, -0.5), new THREE.Vector3(0.5, 0.5, -0.5)];
            geometry0.faces = [new THREE.Face3(3, 2, 1), new THREE.Face3(3, 1, 0), new THREE.Face3(4, 5, 6), new THREE.Face3(4, 6, 7), new THREE.Face3(0, 1, 5), new THREE.Face3(0, 5, 4), new THREE.Face3(1, 2, 6), new THREE.Face3(1, 6, 5), new …
Run Code Online (Sandbox Code Playgroud)

javascript three.js raycasting

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

从Wiki页面获取整洁的内容.(MediaWiki API)

我希望以这种格式(下图)从Wiki获取内容页面,然后在WebView中显示它.这意味着内容包括文本和链接.

爱因斯坦

我试过这个,但输出似乎很乱. http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=Albert_Einstein&format=xmlfm

android mediawiki wikipedia-api

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

angularjs在selectall上切换并取消选择

我使用以下AngularJS代码...

<div ng-controller="MyCtrl">

   <h4>I have {{friends.length}} friends. They are...</h4>

<span id="selectall" ng-click="selectAllFriends()"><u>Select All</u></span>  <br>

<ul class="example-animate-container">
<li class="animate-repeat" ng-repeat="friend in friends">
<input 
type="checkbox" 
value="{{friend.id}}"
ng-checked="friend.checked"
ng-model="friend.checked"
>
{{friend.id}} {{friend.name}} who is {{friend.age}} years old.
</li>
</ul>

<pre><strong>{{selectedFriends().length}} selected with filter:</strong> {{friends | filter:{checked:true} | json}}</pre>

<script>
function MyCtrl($scope, $filter) {
  // fruits
  $scope.friends = [
                        {id: 1, name:'John', age:25, gender:'boy'},
                        {id: 2, name:'Jessie', age:30, gender:'girl'},
                        {id: 3, name:'Johanna', age:28, gender:'girl'},
                        {id: 4, name:'Joy', age:15, gender:'girl'},
                        {id: 5, name:'Mary', age:28, gender:'girl'}, …
Run Code Online (Sandbox Code Playgroud)

checkbox angularjs

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