我正在使用ember-cli来构建我的应用程序,它为我提供了一个很好的app.js文件,我可以在静态资产服务器上提供该文件。在部署时允许单独配置的最惯用的方法是什么?
例如,我可能会告诉我的app.js文件的使用者包含一个config.[js|json]将被加载的额外文件,并且该文件中的值将进入ENV对象......以便我可以将应用程序指向不同的 REST 端点,例如(QA、沙盒、预发布等)而无需重新编译。
我想一定有办法,我只是没有看到。我知道有config/environment.js文件,但它被编译到dist文件夹中。我正在寻找位于打包 JS 旁边的东西。我当然可以一起破解一些东西,所以我不是在寻找黑客。一个ember-cli-addon,也许?我认为必须有一种“余烬方式”来做到这一点。
我只是没有找到它:)
configuration ember.js ember-data ember-cli ember-cli-addons
我有一个像示例中的视频集: autoresize=true naturalWidth=1280 naturalHeight=720 这是实际大小,但出现以下错误。即使我取消尺寸并保留 autoresize=true 仍然会出现错误。
VIDEOJS:错误:为高度提供的值“NaN”不正确
任何人都可以帮忙吗?
我正在尝试通过 ember-cli 在我的 Ember 应用程序中加载gridstack。我通过安装应用程序bower并导入到我的ember-cli-build.js文件中。它_通过以下方式作为库包括:
if (typeof define === 'function' && define.amd) {
define(['jquery', 'lodash'], factory);
}
Run Code Online (Sandbox Code Playgroud)
define.amd 评估为 false
我调查了为什么会这样,发现 ember-cli 的加载器不支持UMD. 在开放 cli问题上,主要 cli 开发人员之一 Stefan Penner 建议:
这是设计使然。因为这个库需要一个预构建步骤来对模块进行去匿名化。该步骤可以进行适当的修改以正常工作
我不知道这意味着什么。我通过ember-cli-build在这个库之前手动导入这个库的依赖项来解决这个问题,但这违背了依赖项管理的目的。我怎样才能让这个库解析它自己的模块?
我需要触发窗口滚动事件来测试无限滚动,我尝试使用triggerEvent,但似乎我错过了一些东西并且它不起作用。我正在使用 Ember 2.0,如果重要的话,列表会在组件内部呈现。最后 2 个断言的测试失败,触发事件后滚动位置不会改变
test 'loads more items when scrolling', (assert) ->
visit '/locations/1'
andThen ->
assert.equal(find('.items-list li').length, 30)
find(window).scrollTop(10000)
triggerEvent(window, 'scroll')
andThen ->
assert.ok(find(window).scrollTop() > 0, 'window should scroll')
assert.ok(find('.items-list li').length > 30, 'should load more items after reaching threshold')
Run Code Online (Sandbox Code Playgroud)
有没有人在他们的测试中成功触发滚动事件?
自从更新到 ember-cli 1.13.8 和 Ember 2.0.0(从 1.13.1 / 1.12.x)以来,我无法让测试套件在 CircleCI 上运行,因为出现错误:
不好 1 PhantomJS - 浏览器“phantomjs /home/ubuntu/app-name/node_modules/ember-cli/node_modules/testem/assets/phantom.js http://localhost:7357/7887”意外退出。 1..1 测试1 通过 0 失败1 npm 错误!测试失败。请参阅上文了解更多详情。 npm 测试返回退出代码 1
它以前可以工作,奇怪的是,它可以在本地工作(OS X El Capitan,PhantomJS 2.0)。在 CircleCI 上,它也运行在 2.0 版本上,安装方式如下:
$ sudo apt-get update; sudo apt-get 安装 libicu52 $curl --output /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic https://s3.amazonaws.com/circle-support-bucket/phantomjs/phantomjs-2.0.1-linux-x86_64 -动态的 $ chmod a+x /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic $ sudo ln -s --force /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic /usr/local/bin/phantomjs
也尝试从 Travis 下载它,但仍然发生同样的事情。
知道原因是什么以及如何解决吗?
--使用 Ember 数据 2.7.1--
我试图颠倒记录集合的顺序,而无需先使用 toArray() 将它们转换为数组。这个对象集合来自 this.store.findAll('history-item') 返回的 promise。
我想以 ember 的方式做到这一点,而不是让它们成为普通的 javascript。我收到来自 record-array.js 的 TypeError: internalModel.getRecord。出于某种原因,当它尝试执行 objectAtContent() 时,它正在查看的内容似乎没有类型。通过堆栈跟踪,我可以看到我正在处理的对象是 [Class],类是历史项目模型。在 objectAtContent() 之前的一些堆栈调用,正在处理的对象从那个历史项目模型切换到其他没有类型属性的 Class 对象。
我能够使用 Ember Inspector 正确查看我的数据,如果我只是在我的模板上显示原始记录集合,它会正确显示。
有没有人遇到过这个?
一些想法和考虑:
- findAll() 如何使用它的承诺,因为它在后台重新加载而不允许逆转,这有什么特别之处吗?我确实希望它继续重新加载实时数据。
-我正在使用 ember-cli-mirage 来模拟我的数据库和端点,并且我已经按照我认为的信件中的说明进行操作。我将未配置的 JSONAPISerializer 用于海市蜃楼,并使用未配置的 JSONAPIAdapter 用于 ember。它与从后面发送的元数据有什么关系吗?它可能与未设置的模型或记录有关吗?我有什么特别的事情要做吗?
定义模型并尝试反转它的路由段:[注意:我知道在路由中准备数据(排序)可能不是惯例,但为了便于描述,我只是把它放在这里。我通常在控制器或组件的外部进行]
model(){
return this.get('store').findAll('history-item').then(function(items){
return items.reverseObjects();
}).catch(failure);
Run Code Online (Sandbox Code Playgroud)
历史列表模型声明:
export default DS.Model.extend({
question: DS.attr('string'),
answer: DS.attr('string')
});
Run Code Online (Sandbox Code Playgroud)
Ember-Cli-Mirage config.js 端点:
this.get('/history-items', (schema) => {
return schema.historyItems.all();
});
Run Code Online (Sandbox Code Playgroud)
历史项目的 Ember-Cli-Mirage 固定装置:
export default [
{id: 1, question: "1is this working?", …Run Code Online (Sandbox Code Playgroud) 我有点沮丧,在任何常见的 IDE(如 VS Code、Webstorm、Atom)中似乎都没有任何像样的“Ember 智能感知”。通过“智能感知”,我的意思是,只要我的 Ember 项目是一个标准的 Ember CLI 项目,其中包含所有常见的服务、帮助程序文件夹等,并且我注入了一个服务myService: service(),例如使用,这将被智能感知识别,并且在输入后this.myService,我会看到服务中的所有功能。此外,如果我 Ctrl+单击 中的函数this.myService.myFunction(),我希望导航到 myFunction 的定义。
对于其他框架,例如 Angular,有支持所有这些的插件。
Is it really the case that I have to use "Find in Files" to find the definition of a service function?
Does anyone know of a way or tool which I might have missed, and which would support this scenario? Note that I don't speak of bare-bones features such as switching between router/controller/template, but of real intellisense …
以前,当我开发ember应用程序时,我使用App作为我的全局对象,并且每个类都存储在这个大对象中.
像这样
window.App.MyModel = Em.Object.extend({});
Run Code Online (Sandbox Code Playgroud)
在浏览器控制台中,我能够做到
App.MyModel.create();
Run Code Online (Sandbox Code Playgroud)
所以我很容易访问MyModel类.
现在我开始使用Ember-CLI进行实验,我对这种工具没有多少经验.我按照文档,然后像这样创建了我的模型服务.
var Service = Ember.Object.extend({});
export default Service
Run Code Online (Sandbox Code Playgroud)
但是现在,如何从浏览器控制台访问Service类?我发现的唯一方法是:
App.__container__.resolve('model:service')
Run Code Online (Sandbox Code Playgroud)
但我不喜欢它.还有更好的方法吗?顺便问一下,您能解释一下出口是如何运作的吗?或者是否有一些我可以研究它的来源(文档,文章)?
非常感谢您的回复.
我最近更新了ember-cli从项目0.0.44到0.1.1和所有的突然我的模板不装了,而是我得到的控制台上的以下警告:
Could not find "application" template or view. Nothing will be rendered Object {fullName: "template:application"}
Could not find "index" template or view. Nothing will be rendered Object {fullName: "template:index"}
Run Code Online (Sandbox Code Playgroud)
我用来更新项目的步骤只是:
npm install --save-dev ember-cli
ember init
Run Code Online (Sandbox Code Playgroud)
这是我的路由器:
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('login');
this.route('permission');
this.route('user');
this.route('room');
this.route('room/new');
});
Router.reopen({
notifyGoogleAnalytics: function() {
return window.ga('send', 'pageview', {
'page': this.get('url'),
'title': this.get('url')
});
}.on('didTransition') …Run Code Online (Sandbox Code Playgroud) 我正在集成一个ember-cliapp,里面my main site可以访问urlhttp://host/faq/....ember...routes
所以我加入baseUrl: /faq/了我的余烬
配置/ environment.js
module.exports = function(environment) {
var ENV = {
modulePrefix: 'faq',
environment: environment,
baseURL: '/faq/',
locationType: 'hash',
Run Code Online (Sandbox Code Playgroud)
问题:在我的ember-cli环境中开发ember server我的资产,如(SVG,FONTS和IMAGES),现在给我一个NOT FOUND.
例如:http://host/assets/images/bg.png给我一个现在没有找到的预期http://host/faq/assets/images/bg.png.为什么会这样?
ember-cli ×10
ember.js ×9
ember-data ×2
javascript ×2
intellisense ×1
phantomjs ×1
promise ×1
video.js ×1
webstorm ×1