小编Jes*_*son的帖子

任务"默认"不在您的gulp文件中

我在我的控制台中运行gulp我收到此错误:

任务'default'不在你的gulpfile中

我的gulpfile看起来很好:

var gulp = require('gulp'),
    LiveServer = require('gulp-live-server'),
    browserSync = require('browser-sync');

gulp.task('live-server', function () {
    var server = new LiveServer('server/main.js');
    server.start();
});

gulp.task('serve', ['live-server'], function () {
    browserSync.init(null, {
        proxy: "http://localhost:3000",
        port: 9001
    });
});
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm gulp

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

paypal快速结账安全与cilent ajax电话

paypal的新结账让我觉得不安全,用户不能在无声的一面触发假付款?

提供的代码如下所示

paypal.Button.render({  
    env: 'sandbox',
    client: {
        sandbox: 'AapGZeCaaDK_q_KPeG19DHnD_kd18vr6BxNe4P6uuhfTKPjIedtNEI9plyDgmzfyI-xGhbxjpv0k-Ha9',
        production: 'xxxxxxxxx' // u expose the key to client side? is this ok?
    },
    payment: function() {
        var env    = this.props.env;
        var client = this.props.client;

        return paypal.rest.payment.create(env, client, {
            transactions: [{
                amount: { total: ($scope.number_of_uses * 9) + '.00' , currency: 'USD' },
                item_list: {
                    items: [{
                        "name": "example",
                        "quantity": $scope.number_of_uses,
                        "price": "9.00",
                        "currency": "USD"
                    }]
                }
            }],
            redirect_urls: {
                "return_url": $location.absUrl(),
                "cancel_url": $location.absUrl()
            }
        });
    },

    onAuthorize: function(data, actions) { …
Run Code Online (Sandbox Code Playgroud)

javascript jquery paypal paypal-sandbox node.js

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

angularjs时刻解析格式

我有一个ng-repeat,显示以下表达式

{{date}} // 2-1-2017
Run Code Online (Sandbox Code Playgroud)

当我使用角度矩

{{date | amDateFormat:'DD'}} 
Run Code Online (Sandbox Code Playgroud)

我得到1,我期待2.如何让我知道我的格式实际上dd-mm-yyyy不在mm-dd-yyy视图中?我不想在我的控制器级别解析它,因为它很复杂.

javascript datetime angularjs momentjs angular-moment

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

jsx if else快捷方式隐藏元素

我可以

<p>Company: {{this.state.user.company}}</p>
Run Code Online (Sandbox Code Playgroud)

但是有时候公司没有价值。那么我应该如何隐藏整个

公司财产是否为空?

我试过了

<p>({this.state.user.company} ? 'Company: ' + {this.state.user.company} : '')</p>
Run Code Online (Sandbox Code Playgroud)

但这是行不通的。

javascript if-statement ecmascript-6 reactjs react-jsx

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

git pull 后解决冲突

但是接下来该怎么办?

$ git pull
Auto-merging views/upload_photo.handlebars
CONFLICT (content): Merge conflict in views/upload_photo.handlebars
Automatic merge failed; fix conflicts and then commit the result.

James@DESKTOP-8VLS7EG MINGW64 ~/Documents/project (master|MERGING)
$ git merge --abort

James@DESKTOP-8VLS7EG MINGW64 ~/Documents/project.my (master)
$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        views/upload_photo_BACKUP_4736.handlebars
        views/upload_photo_BASE_4736.handlebars …
Run Code Online (Sandbox Code Playgroud)

git github

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

Mongoose save()不是一个函数

在我的app.js中,我需要我的模型

var User = require('./models/user');
app.post('/user/add', function(req,res,next){
  var newUser = new User();
  newUser.add(req.body.name, function(response){
    res.json(response);
  })
});
Run Code Online (Sandbox Code Playgroud)

我的模型(user.js)看起来像这样

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var userSchema = new Schema({
    name: String
});
var User = module.exports = mongoose.model('user', userSchema);
module.exports.add = function(name,callback){
    User.save({name:name}).exec(callback);
}
Run Code Online (Sandbox Code Playgroud)

但我得到newUser.add的错误不是一个函数?

javascript mongoose mongodb node.js

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