小编Hel*_*rld的帖子

使用 hexo.io 创建 db.json 文件并将其添加到 .gitignore

我一直在试图找出 adb.json是什么以及为什么它会自动生成。hexo.io 中的所有文档都是:

$ hexo clean

Cleans the cache file (db.json) and generated files (public).
Run Code Online (Sandbox Code Playgroud)

这到底是什么?由于这些都是静态页面,这是某种临时数据库吗?

json hexo

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

filter vs map reactjs and jsx

I'm working on a react project to learn react.

In a component's render method, when I use .map to iterate over values and return an array of components, everything works as expected.

<ol className="books-grid">
        {              
          books && books.map((book, index) => {
            if (book.shelf === shelf) {
              return (
                <Book key={book && book.id ? book.id : index} changeShelf={this.props.changeShelf} book={book} />
              );
            }
          })}
      </ol>
Run Code Online (Sandbox Code Playgroud)

But when I use filter:

<ol className="books-grid">
            {              
              books && books.filter((book, index) => {
                if (book.shelf …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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

控制器未在View中定义

角度错误:错误:参数'StoreController as store'不是函数,未定义

index.html

<!DOCTYPE html>
<!-- runs the module when the document loads -->
<html ng-app='store'>
    <head>
        <link rel='stylesheet' type='text/css' href='http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css'/>
    </head>
    <body>

        <!-- expressions -->
            <!-- directive    controller name    alias -->
        <div ng-controller='StoreController as store'>
            <h1> {{store.product.name}} </h1>
            <h2>${{store.product.price}}</h2>
            <p>{{store.product.description}}</p>
        </div>
        <script type = 'text/javascript' src='https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js'></script>
        <script type ='text/javascript' src='app.js'></script>
    </body>
</html>

app.js

// wrap the function inside a closure.
(function(){
var app = angular.module('store', []);

app.controller('StoreController', function(){
    // will be executed when the store controller is called. …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

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

使用 - 而不是value = value - 1不能正确更新.html

我试图确定为什么我得到以下行为.这是我想要更新的div:

<h3 id='guess-count'> 5 Guesses Remaining </h3>
Run Code Online (Sandbox Code Playgroud)

工作守则:

$('#guess-count').html(startingCount = startingCount - 1 + " Guesses Remaining");
Run Code Online (Sandbox Code Playgroud)

这将显示startingCount变量的更新值.

非工作

$('#guess-count').html(startingCount-- + " Guesses Remaining");
Run Code Online (Sandbox Code Playgroud)

当我介入调试器时,我看到值确实发生了变化,但它没有在html视图中表达.但是,如果我再次运行它,它确实更新了html值,但是在它减去一个之前它的值是多少.这是一个例子:

// starting value and first pass
startingCount = 5

 $('#guess-count').html(startingCount-- + " Guesses Remaining");

// startingCount html display value is 5 BUT startingCount holds the value of 4

startingCount = 4
//second pass
$('#guess-count').html(startingCount-- + " Guesses Remaining");

// startingCount html display value is 4 BUT startingCount holds the value of 3
Run Code Online (Sandbox Code Playgroud)

它似乎显示了startingCount的当前值,然后从其值中减去一个值.

有谁知道为什么这样做?它似乎在更新html后评估'startingCount--'.

html javascript jquery

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

++ num和num ++之间的区别

阅读这两篇文章后:

我仍然对以下代码感到困惑:

var num = 0;

num++ // returns 0

++num // returns 1
Run Code Online (Sandbox Code Playgroud)

为什么剂量num++返回0?

我知道它先分配,然后再添加一个,但是我仍然不明白为什么它不显示1。

var num = 0;

num++ // returns 0

num // returns 1
Run Code Online (Sandbox Code Playgroud)

我对以下示例感到非常困惑:

例:

var num = 0;

num++
// assigns then increments

// So if it assigns the num = 0, then increments to 1, Where is one being 
//stored? Is it assigned anywhere?
Run Code Online (Sandbox Code Playgroud)

还是分配表达式。

(我想表达是这样的:num = num + 1;)

这可能是我的最佳猜测,但对我来说还不是100%清楚,我仍然不明白为什么num ++显示/返回0而不是对表达式求值并返回1。

javascript

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

标签 统计

javascript ×4

angularjs ×1

hexo ×1

html ×1

jquery ×1

json ×1

reactjs ×1