如何使用需要和凉亭的砌体3.0

时间:2013-07-20 15:35:51

标签: require jquery-masonry bower

我在我的项目中安装了masonry 3.0,但出现了一些错误:

GET http://localhost:3000/get-style-property/get-style-property.js 404 (Not Found) require.js:1880
Uncaught Error: Script error for: get-style-property/get-style-property
http://requirejs.org/docs/errors.html#scripterror require.js:163
GET http://localhost:3000/get-size.js 404 (Not Found) require.js:1880
Uncaught Error: Script error for: get-size
http://requirejs.org/docs/errors.html#scripterror require.js:163
GET http://localhost:3000/.js 404 (Not Found) require.js:1880
Uncaught Error: Script error for: 
http://requirejs.org/docs/errors.html#scripterror require.js:163

致力于:

mac 10
bower 0.10
node 0.10.8

我的bower.json:

{
  "name": "kethervideo",
  "version": "0.0.1",
  "dependencies": {
    "jquery": "~2.0.3",
    "requirejs": "~2.1.5",
    "underscore": "~1.4.4",
    "masonry": "~3.0.3",
    "imagesloaded": "~3.0.1"
  }
}

my requirejs config:

requirejs.config({
    paths: {
        jquery: 'bower_components/jquery/jquery'
        , underscore: 'bower_components/underscore/underscore'
        , eventEmitter: 'bower_components/eventEmitter/EventEmitter'
        , eventie: 'bower_components/eventie/eventie'
        , getSize: 'bower_components/get-size/get-size'
        , getStyleProperty: 'bower_components/get-style-property/get-style-property'
        , outlayerItem: 'bower_components/outlayerAmd/item'
        , outlayer: 'bower_components/outlayerAmd/outlayer'
        , masonry: 'bower_components/masonry/masonry'
        , imagesloaded: 'bower_components/imagesloaded/imagesloaded'

    }
    , shim:{
        "underscore": ["jquery"]
        , "masonry": ["jquery"]
        , "imagesloaded": ["jquery"]
    }
});

我不知道它有什么问题,我把所有包装都包含在砌体里面。

4 个答案:

答案 0 :(得分:1)

除了其他人的所有建议外,我不确定砌筑是否需要在3.1版之前准备就绪 见这里:https://github.com/desandro/masonry/issues/296#issuecomment-21685501

使用3.1,您可以按照此处的说明进行操作:

http://masonry.desandro.com/appendix.html

requirejs.config({
  paths: {
    eventie: 'bower_components/eventie',
    'doc-ready': 'bower_components/doc-ready',
    eventEmitter: 'bower_components/eventEmitter',
    'get-style-property': 'bower_components/get-style-property',
    'get-size': 'bower_components/get-size',
    'matches-selector': 'bower_components/matches-selector',
    outlayer: 'bower_components/outlayer',
    masonry: 'bower_components/masonry'
  }
});

requirejs( [ 'masonry/masonry' ], function( Masonry ) {
  new Masonry( /*...*/ )
});

答案 1 :(得分:0)

您正在使用camelCase路径,在这种情况下它们似乎是破折号。尝试一下它应该可以工作。

答案 2 :(得分:0)

问题是路径中键的名称。

如果你检查getSize.js的底部,你会注意到它

define( [ 'get-style-property/get-style-property' ], defineGetSize );

它将检查配置是否有别名,如果找不到,则会检查相对路径;这就是你得到404错误的原因

将配置更改为类似下面的内容应修复404错误

requirejs.config({
    paths: {
        jquery: 'bower_components/jquery/jquery'
        , underscore: 'bower_components/underscore/underscore'
        , eventEmitter: 'bower_components/eventEmitter/EventEmitter'
        , eventie: 'bower_components/eventie/eventie'
        , 'get-size/get-size': 'bower_components/get-size/get-size'
        , 'get-style-property/get-style-property': 'bower_components/get-style-property/get-style-property'
        , outlayerItem: 'bower_components/outlayerAmd/item'
        , outlayer: 'bower_components/outlayerAmd/outlayer'
        , masonry: 'bower_components/masonry/masonry'
        , imagesloaded: 'bower_components/imagesloaded/imagesloaded'

    }
    , shim:{
        "underscore": ["jquery"]
        , "masonry": ["jquery"]
        , "imagesloaded": ["jquery"]
    }
});

答案 3 :(得分:0)

.bowercc 文件中的目录路径设置为" app / scripts"并执行 bower install