小编Spi*_*886的帖子

JavaScript:var {left,... props} = this.props;

我正在阅读Facebook的固定数据表的源代码,我发现了这一点

var {left, ...props} = this.props;
Run Code Online (Sandbox Code Playgroud)

这意味着什么?这是一个新的语义?我很困惑

javascript ecmascript-6 reactjs

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

配置karma.js以使用react和ES6

我尝试用ES6开发一个反应模块,找不到任何发电机,所以我必须从一个基本的.我能够配置几乎所有的东西,但我有很多问题尝试配置业力,测试我的模块.

这是我的karma.conf.js

// Karma configuration
// http://karma-runner.github.io/0.12/config/configuration-file.html
// Generated on 2015-03-17 using
// generator-karma 0.9.0

module.exports = function(config) {
  'use strict';

  config.set({
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // base path, that will be used to resolve files and exclude
    basePath: '../',

    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['commonjs', 'mocha', 'chai'],

    // list of files / patterns to load in the browser
    files: [
      'node_modules/karma-babel-preprocessor/node_modules/babel-core/browser-polyfill.js',
      'node_modules/react/react.js',
      'lib/**/*.js',
      'test/**/*.js'
    ],
    preprocessors: …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 karma-runner reactjs yeoman-generator

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

葡萄:葡萄实体需要的参数

我正在编写一个带有葡萄的API服务器,我选择使用葡萄实体,因为它能够自动生成swagger的文档.但是,当我根据需要设置一个参数时,我有一个问题.因为葡萄不能证实参数存在.看起来葡萄忽略required: true了实体的参数.

app.rb

module Smart
  module Version1
    class App < BaseApi

      resource :app do

        # POST /app
        desc 'Creates a new app' do
          detail 'It is used to re gister a new app on the server and get the app_id'
          params  Entities::OSEntity.documentation
          success Entities::AppEntity
          failure [[401, 'Unauthorized', Entities::ErrorEntity]]
          named 'My named route'
        end
        post do
          app = ::App.create params
          present app, with: Entities::AppEntity
        end
      end
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

os_entity.rb

module Smart
  module Entities
    class OSEntity < Grape::Entity

      expose …
Run Code Online (Sandbox Code Playgroud)

ruby api ruby-on-rails ruby-grape grape-entity

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

防止安装 PWA

有什么方法可以配置我manifest.json禁用浏览器弹出窗口,要求“安装”站点?我正在使用以下 JavaScript 代码来防止它:

window.addEventListener('beforeinstallprompt', function(e) {
    e.preventDefault();
    return false;
});
Run Code Online (Sandbox Code Playgroud)

但是我也需要在 AMP 版本上阻止它,而且我无法在那里运行 JavaScript 代码。

javascript service-worker amp-html progressive-web-apps manifest.json

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