【问题标题】:I need a strongloop example wrote in javascript without angular我需要一个用 javascript 编写的没有角度的强循环示例
【发布时间】:2014-10-28 05:25:44
【问题描述】:

我想要一个只使用没有角度的javascript的强循环示例。 目前没有没有角度的完整工作示例。 我想简单地将 browser.bundle.js 包含在我的 index.html 中,然后从/到服务器端同步数据。事实上,我正在尝试在我的程序中替换 pouchdb,因为 couchdb 在开源社区中似乎并不成功。

我无法正确跟进此文档: Running Loopback in the browser

  1. 使用来自Running Loopback in the browser 的内容创建 browser-app.js
  2. 复制过去的内容到 browser-app.js
  3. npm install loopback loopback-boot
  4. browserify browser-app.js -o app.bundle.js 然后我得到错误:错误:找不到模块 'loopback-boot#instructions' from '/Users/simba/Projects/traveller-app/client/node_modules/环回引导'

【问题讨论】:

  • 您具体需要什么示例?据我了解,StrongLoop 是 Node.JS 的 REST API 框架。你需要一些例子来说明如何在 StrongLoop 中工作吗?您是否需要有关如何使用 JavaScript 与 RESTful API 交互的示例...?
  • 是的,我需要在 phonegap 中写一个客户端。我想简单地将 browser.bundle.js 包含在我的 index.html 中,然后从/到服务器端同步数据。事实上,我正在尝试在我的程序中替换 pouchdb/couchdb,因为 couchdb 在开源社区中似乎并不成功。

标签: javascript html node.js offline strongloop


【解决方案1】:

这有几个步骤,但很简单。

  1. 通过slc loopback 引导您的应用程序。
  2. 删除server/boot/root.js
  3. 取消注释server/server.js 中的两行,应该是这样的:

    ...
    // -- Mount static files here--
    // All static middleware should be registered at the end, as all requests
    // passing the static middleware are hitting the file system
    // Example:
    var path = require('path'); //this line is now uncommented
    app.use(loopback.static(path.resolve(__dirname, '../client'))); //this line is now uncommented
    ...
    
  4. 使用您的内容在client 目录(即client/index.html)中创建index.html

这应该可以让您通过基本的前端工作进行基本设置。如果您还有其他问题,请告诉我。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-07
  • 1970-01-01
  • 2017-12-24
  • 1970-01-01
  • 1970-01-01
  • 2020-09-10
  • 1970-01-01
相关资源
最近更新 更多