1

I am building a simple POC using famo.us. I would like to use the device view from the famo.us University lessons but when I write this code (slightly modified from what I found in the tutorials) nothing renders:

/*globals define*/
define(function(require, exports, module) {
    // import dependencies
    var Engine = require('famous/core/Engine');
    var ImageSurface = require('famous/surfaces/ImageSurface');
    var StateModifier = require('famous/modifiers/StateModifier');
    var DeviceView = require('./DeviceView');

    // create the main context
    var mainContext = Engine.createContext();

    // your app here
    var logo = new ImageSurface({
        size: [267, 102],
        content: '/content/images/t-logo-black.png'
    });

    var logoModifier = new StateModifier({
        origin: [0.5, 0.5]
    });
    var logoNode = mainContext.add(logoModifier);

    logoNode.add(logo);
});

It appears that just adding the line var DeviceView = require('./DeviceView'); is what is causing the problem because just adding that one line to a working app seems to make everything not work that was working before. So I have 2 questions:

  1. How do I make the require for DeviceView work
  2. Is there a place I can go to find this sort error? Right now a blank screen is not very helpful. :)

Thank you!

4

4 回答 4

2

设备视图不是当前的开源视图。我听说他们正在消除一些错误,但很快就会发布。

下次您看到没有加载的内容时,请务必检查目录,以确保文件确实存在。

到目前为止,我发现使用着名的调试有点棘手。真正针对您的问题,只有控制台才能为您提供所需的内容。在视图的情况下,如果它没有按我的预期显示,我经常将一个 id 或类放入视图中,因为它可以在 DOM 中搜索。

创建更好的调试工具将添加到 famo.us 未来几个月要构建的长长列表中。作为早期采用者,这是一条艰难的道路。

祝你好运!

于 2014-05-04T03:18:41.340 回答
1

使其工作添加此代码: //var DeviceView = require('DeviceView'); var View = require("着名/核心/视图");

在 createDevice() 函数更改中:

device = new View(deviceOptions);

var deviceModifier = new StateModifier({
    size: [300,400],
    origin: [0.5, 0.5]
});

注释掉任何 GlobalEvents。

于 2014-05-19T04:37:58.500 回答
0

https://github.com/hinablue/ Famous.tw/tree/master/deviceView

那部分是因为错误..看看上面的链接这是为课程制作的自定义视图,没有提供著名的下载包。您可以检查课程页面的源代码并尝试从该 JS 文件中发现 URL……但我认为这不会那么容易。

于 2014-06-15T14:30:11.883 回答
0

这是为课程制作的自定义视图,没有提供著名的下载包。您可以检查课程页面的源代码并尝试从该 JS 文件中发现 URL……但我认为这不会那么容易。

于 2014-05-04T03:08:17.980 回答