【问题标题】:Is it possible to use Onsen UI 2 in Meteor with React是否可以通过 React 在 Meteor 中使用 Onsen UI 2
【发布时间】:2016-04-19 16:46:01
【问题描述】:

我希望在 Meteor 中测试新的 beta Onsen UI 2。我尝试使用 meteorhack 和 browserify 创建一个包。

https://onsen.io/2/

我遵循的步骤是:

add meteorhacks and browserify

meteor 添加meteorhacks:npm cosmos:browserify 将 onsenui 添加到 packages.json

{
   "onsenui" : "2.0.0-beta"
}

将其添加到 lib/app.browserify.js

 OnsenUi = require('onsenui/js/onsenui');

然后我尝试运行应用程序,但一直遇到同样的问题。

W20160325-14:40:26.163(2)? (STDERR)                         throw(ex);
W20160325-14:40:26.163(2)? (STDERR)                               ^
W20160325-14:40:26.340(2)? (STDERR) ReferenceError: window is not defined
W20160325-14:40:26.340(2)? (STDERR)     at defineProperty (node_modules/onsenui/js/onsenui.js:6:1)
W20160325-14:40:26.340(2)? (STDERR)     at Object.<anonymous> (node_modules/onsenui/js/onsenui.js:175:1)
W20160325-14:40:26.340(2)? (STDERR)     at Object._process (node_modules/onsenui/js/onsenui.js:19919:1)
W20160325-14:40:26.340(2)? (STDERR)     at s (../../../../../../../.meteor/packages/cosmos_browserify/.0.10.0.1e53wt8++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/CosmosBrowserify/node_modules/browserify/node_modules/browser-pack/_prelude.js:1:1)

我在想,由于这个新版本与 React 兼容并且不再需要 Angular,这应该是可能的吗?

【问题讨论】:

    标签: node.js meteor reactjs browserify onsen-ui2


    【解决方案1】:

    meteorhacks 和 browserify 的结合对我来说从来都不是很好。尝试使用 Meteor 1.3,它支持 npm 开箱即用。 当我尝试将 Material-UI 用于流星项目时,更新到 1.3 解决了我的问题。

    您可以使用以下命令升级到流星 1.3。 (请务必先备份您的项目)

    meteor remove meteorhacks and browserify
    meteor update --release 1.3-rc.12
    npm install onsenui@2.0.0-beta --save
    

    他们再次尝试运行流星。

    【讨论】:

    • 升级到 1.3 以获得更好的 NPM 支持听起来是个好主意,但我在 ios 模拟器上运行升级后的应用程序时遇到问题。构建成功,即使使用 --verbose 我也看不到任何错误,但应用程序卡在启动画面上。我什至尝试使用标准测试数据创建一个新项目并在模拟器中运行它。同样,1.2 运行良好,但 1.3 卡在初始屏幕上。我正在 Meteor 论坛上寻找,看看是否有人知道原因。
    • 就像一个注释 - 它有点愚蠢但是 - 升级后我需要第一次运行 ios-device 然后从 Xcode 运行模拟器。之后我可以像以前一样使用meteor run ios。
    • 很好地解决了这个问题。抱歉,由于我没有使用 Meteor 进行移动开发,因此无法为您提供帮助。
    猜你喜欢
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    • 2017-09-16
    • 2018-09-15
    • 1970-01-01
    • 2014-11-11
    • 2017-03-19
    • 2018-08-11
    相关资源
    最近更新 更多