【问题标题】:Cordova nodejs routing issueCordova nodejs路由问题
【发布时间】:2017-07-08 13:31:29
【问题描述】:

我是科尔多瓦的新手。

我正在尝试使用 nodejs 作为后端来构建 cordova 应用程序。当我使用 browser (cordova run browser) 运行应用程序时,它会将我重定向到 http://localhost:8000/index.html,这很好。

我的问题是,当我登录网站时,浏览器重定向到“http://localhost:8000/home”并给出未找到错误。我已将 routes.js 的路由设置为“/home”(nodejs 后端)。

任何帮助将不胜感激。谢谢。

【问题讨论】:

  • 发布代码..

标签: javascript node.js cordova routing


【解决方案1】:

你有什么东西可以用来路由视图吗

router.addRoute('name of view',function(){'your code here'})

【讨论】:

  • > 在服务器端:nodejs (routes.js) app.get('/login', function (req, res) { if(login.auth(req, res)) res.redirect(host+':8080/home'); else res.render('index.html'); }); app.get('/home', function (req, res) { if(login.auth(req, res)) res.render('home.html'); else res.redirect(host+':8080/login'); }); cordova 应用程序 上未完成路由。我也必须在 cordova 应用程序上进行路由吗?
猜你喜欢
  • 1970-01-01
  • 2018-04-30
  • 1970-01-01
  • 2013-05-14
  • 2021-03-08
  • 2023-04-04
  • 1970-01-01
  • 2017-03-26
  • 1970-01-01
相关资源
最近更新 更多