小编vam*_*olu的帖子

Handlebars 2.0运行时出现未知模板对象错误

我已将我的所有代码发布为使用express来加载静态内容的runnable

我已经预编译了这个把手模板:

 <img src="{{coverImage}}"/>
<ul>
    <li>{{title}}</li>
    <li>{{author}}</li>
    <li>{{releaseDate}}</li>
    <li>{{keywords}}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

删除

我已经获得了这个功能:

    (function() {
  var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['bookTemplate'] = template(function (Handlebars,depth0,helpers,partials,data) {
  this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression;


  buffer += "<img src=\"";
  if (helper = helpers.coverImage) { stack1 = helper.call(depth0, {hash:{},data:data}); }
  else { helper = (depth0 && depth0.coverImage); stack1 = typeof helper === functionType ? helper.call(depth0, …
Run Code Online (Sandbox Code Playgroud)

javascript exception backbone.js handlebars.js

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

做流浪汉时出错

当我这样做时,我收到此错误vagrant up:

anr@anr-Lenovo-G505s ~ $ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'base' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Adding box 'base' (v0) for provider: virtualbox
default: Downloading: base
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file /home/anr/base
Run Code Online (Sandbox Code Playgroud)

这是我的Vagrantfile:

 # -*- …
Run Code Online (Sandbox Code Playgroud)

virtualbox base vagrant vagrantfile

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

使用redux-saga调度操作时取消传奇

在调度START动作时,我为秒表React组件启动计时器:

import 'babel-polyfill'
import { call, put } from 'redux-saga/effects'
import { delay, takeEvery, takeLatest } from 'redux-saga'
import { tick, START, TICK, STOP } from './actions'

const ONE_SECOND = 1000

export function * timerTickWorkerSaga (getState) {
  yield call(delay, ONE_SECOND)
  yield put(tick())
}

export default function * timerTickSaga () {
  yield* takeEvery([START, TICK], timerTickWorkerSaga)
  yield* takeLatest(STOP, cancel(timerTickWorkerSaga))
}
/*
  The saga should start when either a START or a TICK is dispatched
  The saga should stop running when a stop …
Run Code Online (Sandbox Code Playgroud)

javascript redux redux-saga

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

使用酶测试React组件状态的变化并监视实例方法

我正在开发一个包装器组件,用于在React中平滑地加载图像.我使用含有mocha,chai和sinon的酶对我的组件进行单元测试.在这里的测试中,我试图测试:

  1. 加载图像时更新组件的状态

  2. onLoad调用组件上的实例方法

const wrapper = shallow( );

const onLoad = wrapper.find('img').props().onLoad;
const onLoadSpy = sinon.spy(onLoad); wrapper.update();
const status = wrapper.state().status;
expect(onLoadSpy).to.have.been.called;
expect(status).to.equal('LOADED');

我发现状态更新既不会被酶反映,也不会更新onLoad间谍的通话计数.这是测试的相应代码:

export default class Image extends Component {
  constructor(props) {
    super(props);
    if (props.src != null && typeof props.src === 'string') {
      this.state = {
        status: LOADING,
      };
    } else {
      this.state = {
        status: PENDING,
      };
    }
    this.onLoad = this.onLoad.bind(this);
  }

  onLoad() {
    this.setState({
      status: LOADED,
    });
  }

  render() {
    //lots of code above …
Run Code Online (Sandbox Code Playgroud)

javascript sinon reactjs enzyme chai-enzyme

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

如何为自定义相机设置曝光和白平衡值

如果我在Android自定义相机中初始化相机参数时没有设置曝光和白平衡会发生什么情况.相机是自己处理这些还是我需要在相机初始化时指定值?

我过去遇到了闪光灯问题,将曝光和白平衡设置为特定值可以帮助我克服这些问题.我没有任何计划让用户手动修改曝光和/或白平衡设置.

我有以下代码设置:

if(isSupported(Camera.Parameters.SCENE_MODE_AUTO, mParameters.getSupportedSceneModes()))
    {
        mSceneMode=Camera.Parameters.SCENE_MODE_AUTO;
        mParameters.setSceneMode(mSceneMode);
    }

    int min=mParameters.getMinExposureCompensation();
    int max=mParameters.getMaxExposureCompensation();
    float step=mParameters.getExposureCompensationStep();
    //do i need to setExposureCompensation here??
    if(mSceneMode==Camera.Parameters.SCENE_MODE_AUTO && isSupported(Camera.Parameters.FLASH_MODE_AUTO,mParameters.getSupportedFlashModes()))
    {
            //ususally when I let the flash fire,the image is filled with light
            //all that does is make everything else undecipherable...  
        mFlashMode=Camera.Parameters.FLASH_MODE_AUTO;
        mParameters.setFlashMode(mFlashMode);
    }

        if(isSupported(Camera.Parameters.WHITE_BALANCE_AUTO,mParameters.getSupportedWhiteBalance()))
    {
        mWhiteBalanceMode=Camera.Parameters.WHITE_BALANCE_AUTO;
        mParameters.setWhiteBalance(mWhiteBalanceMode);
    }
Run Code Online (Sandbox Code Playgroud)

我已经读过当应用autoExposureLock和autoWhiteBalanceLock时停止自动曝光和自动白平衡更新周期.为什么以及如何在我的相机代码中使用这些锁?

camera android android-camera

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

找不到模块:无法解析“F:\React\react-complete-guide\src\Component”中的“../axios”

我在React尝试发送GET请求的项目中遇到此编译错误:

./src/Component/Form.js
Module not found: Can't resolve '../axios' in 'F:\React\react-complete-guide\src\Component'
Run Code Online (Sandbox Code Playgroud)

代码:

import React, {Component} from 'react';

import axios from '../axios';

class Form extends React.Component{

state={UserName:""};

onChangeHandle=(event)=>{
    this.setState({UserName:event.target.value});

}

handleSubmit= (event) =>{

event.preventDefault();
console.log('form submit');

axios.get('https://api.github.com/users/${this.state.UserName}')
   .then(
       resp=>{
       console.log(resp);
    })

};


render(){
    return(
        <form onSubmit={this.handleSubmit}>
            <input type="text" 
                placeholder="Github UserName"
                value={this.state.UserName}
                onChange={this.onChangeHandle}   />
            <br/>
            <button type="submit"> Add card </button>
        </form>    
    )}
}

export default Form;
Run Code Online (Sandbox Code Playgroud)

reactjs axios

12
推荐指数
3
解决办法
4万
查看次数

尝试使用android v7 appcompat库时出现奇怪错误

我刚刚在我的项目中包含了android v7-appcompat库.我已经成功地将jar添加到构建路径中,现在我正在使用Theme.AppCompat主题.现在,我得到了这个奇怪的错误:

[Dex Loader]无法执行dex:多个dex文件定义了Landroid/support/v7/app/ActionBar $ Callback; [2013-10-09 11:11:50 - DelTest2]转换为Dalvik格式失败:无法执行dex:多个dex文件定义Landroid/support/v7/app/ActionBar $ Callback;

编辑

我的项目现在包含三个文件夹,每个文件夹包含android v7 appcompat:

+Android Private Libraries
+Android Dependencies
+Referenced Libraries
Run Code Online (Sandbox Code Playgroud)

为了使我的项目有效,我必须删除这些库中的哪一个?

android android-actionbar-compat

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

使用XMLHttpRequest创建CORS Ajax请求

这是根据提供的示例验证geoJSON的代码:

 function processSuccess(data){
            if(data.status==="ok")  console.log("You just posted some valid geoJSON");
            else if(data.status==="error") console.log("There was a problem with your geoJSON "+data.message);
        }
        function processError(data){
            console.log("The AJAX request could not be successfully made");
        }
        $.ajax({
            url: 'http://geojsonlint.com/validate',
            type: 'POST',
            data: geo,
            dataType: 'json',
            success: processSuccess,
            error: processError
        });   
Run Code Online (Sandbox Code Playgroud)

我正在尝试geoJSON使用以下代码进行验证:

  var getXHR=function()
{
    try{return new XMLHttpRequest();}   catch(e){}
    try{return new ActiveXObject("Msxml2.XMLHTTP.6.0");}    catch(e){}
    try{return new ActiveXObject("Msxml2.XMLHTTP.3.0");}    catch(e){}
    try{return new ActiveXObject("Microsoft.XMLHttp");}     catch(e){}
    console.err("Could not find XMLHttpRequest");
};
var makeRequest=function(uri,data)
{
    //make the actual XMLHttpRequest …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery xmlhttprequest cors

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

获取html页面中的url参数

我有一个html页面,使用一个看起来像这样的网址加载:

http://localhost:8080/GisProject/MainService?s=C&o=1
Run Code Online (Sandbox Code Playgroud)

我想在不使用的情况下获取url中的参数jsp.可以使用Javascript或完成jQuery.我想在使用Node.js本地服务器测试我的页面,然后将其部署到使用Java服务器的远程机器中.

有没有可以让我这样做的图书馆.

html javascript jquery

9
推荐指数
3
解决办法
5万
查看次数

从Promise返回一个值

我想使用这样的Promise来调用Google Maps Geocoding API:

function makeGeoCodingRequest(address,bounds)
{
    /*
        Input parameters:
            address:a string
            bounds: an object of class google.maps.LatLngBounds(southWest,northEast)

        This will return a set of locations from the google geocoding library for the given query
     */
    var url="https://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&key=AIzaSyD9GBloPC20X-1kWRo7sm_0z5xvCiaSd3c";
    var promise,response;
    var messages={
            "ZERO_RESULTS":"No results were found",
            "OVER_QUERY_LIMIT":"We are over the query limit.Wait awhile before making a request",
            "REQUEST_DENIED":"Request was denied,probably using a bad or expired API Key",
            "INVALID_REQUEST":"Request was sent without the required address,component or component",
            "UNKNOWN_ERROR": …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery promise q

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