安贝App.router.“应用程序未定义”
Ember App.router. "App not defined"
我第一次尝试路由我的应用程序,但我不太理解逻辑。在route.js文件中添加以下内容时,我渲染了我的模板:
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('main', { path: '/' }, function() {
this.route('helloworld', { path: '/'});
});
});
export default Router;
大多数示例似乎都使用了函数App.router.map进行路由。首先,我不太明白这有什么区别?路由是存储在应用中还是什么。当我想把这个添加到route.js时:
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
App.Router = Ember.Router.extend({
enableLogging: true,
location: 'hash'
});
App.Router.map(function() {
this.route('main');
});
export default Router;
我得到:"Uncaught ReferenceError: App is not defined"。那么正确的方法是什么,我错过了什么?
一般来说,有两种方法来创建Ember应用程序:
- 使用Ember CLI,这是推荐的
- 使用全局变量- App.Router等
在Ember CLI中,你不应该访问全局应用变量。因此,您的router.js
应该看起来像您的第一个代码示例。
App
没有在你的router.js
中定义,因为它不是烬CLI的方式。
在Ember CLI中,您使用模块和文件拆分到许多目录,而不是使用全局变量- App
的一个大文件。
你应该学习更多关于Ember CLI和Ember的基础知识。余烬指南是最好的起点。
相关文章:
- 使用jquery.load('pageName')方法时,未从应用程序缓存加载Html页
- 注入应用程序的角度控制器未定义
- Ionic应用程序在部署后给出ReferenceError:未定义Promise
- Rally自定义应用程序复选框筛选器不工作
- 如何在自定义应用程序中使用后退按钮访问Fiori启动板
- 创建 JavaScript 自定义应用程序的新实例
- 如何定义应用程序的方法
- 尝试使用 SharePoint 2013 的 REST 服务器和 CSOM 时,“未为此应用程序的请求 URL 部署应用
- 从网页打开自定义应用程序
- 未捕获的引用错误:未定义应用,未捕获的语法错误:意外的令牌<.缺少一些东西
- AJAX加载的内容中未定义引导程序日期选择器
- 自定义应用程序启动屏幕
- 自定义应用程序的动态高度
- 绑定后未定义应用程序
- Ext.JS 4.2.1使用Jasmine进行单元测试-未定义应用程序
- 在angular js中的一个单独文件中定义应用程序
- 使用node.js一步一步创建自定义应用程序
- Digital Publishing Suite Web Viewer未显示应用程序
- 有没有办法让窗口在窗口中包含自定义应用程序
- 由于日光节约已经开始,我的自定义应用程序不工作