我通过引用ember.js文件成功地将EmberJS JavaScript框架与ASP.NET Web应用程序一起使用.
我的印象是Ember-CLI是Ember将来未来版本的方式.
如果这是正确的,那么继续使用Ember的适当方法是什么?将Ember-CLI与ASP.NET一起使用是有意义的,还是假设客户端只是静态HTML和CSS/JS回调服务器端代码(例如WebAPI)?
在我的ember-cli应用程序中,我安装了一个名为的插件'ember-cli-selectize'.查看目录结构,我可以看到它的文件位于/node_modules/ember-cli-selectize'.现在我想创建一个扩展此插件的自定义组件.我如何导入/要求它?我试过这些似乎没有工作:
var EmberSelectize = require('/ember-cli-selectize/app/components/ember-selectize');
import EmberSelectize from 'components/ember-selectize';
import EmberSelectize from 'node_modules/ember-cli-selectize/addon/components/ember-selectize';
import EmberSelectize from 'ember-cli-selectize/addon/components/ember-selectize';
我总是得到这个'找不到模块'的错误,无论如何.我需要以某种方式导入/要求它做类似的事情
import EmberSelectize from 'wherever/it/is';
export default EmberSelectize.extend({
//my own customizations
})
Run Code Online (Sandbox Code Playgroud) 我试图导入ember-localstorage-adapter作为
import DS.LSAdapter from "ember-localstorage-adapter";
Run Code Online (Sandbox Code Playgroud)
但我得到了错误
错误:第5行:导入后丢失
我是否需要使用ES6 Module Transpiler编译ember-localstorage-adapter?
我想根据构建环境设置我的RESTAdapter主机.
我假设值可以config/environment.js像这样存储:
if (environment === 'development') {
ENV.API_ENDPOINT = 'http://localhost:8080';
}
if (environment === 'production') {
ENV.API_ENDPOINT = 'http://api.myserver.com';
}
Run Code Online (Sandbox Code Playgroud)
但我不确定如何adapter/application.js在构建过程中插入信息.
我有一个favicon在我的索引模板上工作了一段时间,但没有任何其他模板,现在甚至我的索引模板都不会显示它.
我刚刚开发,所以我正在使用ember server.
的index.html
<link rel="icon" href="favicon.ico">
只是扔在我的图标周围,看它是否出现在任何地方,我现在在以下位置:
app/
public/
public/assets
我认为这应该是非常简单的,特别是因为索引页面没有改变,只是将新的东西加载到它的出口,所以我无法弄清楚为什么它找不到我的favicon文件.
在运行时ember server,/根指向的实际位置是什么?
我有一个mixin app/mixins/ui-listener.js,我很难与Ember-CLI一起使用.我正在尝试使用以下语法的mixin:
import ListenerMixin from './mixins/ui-listener';
export default Ember.Component.extend(ListenerMixin,{
// class definition
}
Run Code Online (Sandbox Code Playgroud)
当我保存它时,这会失败,抱怨
ENOENT,没有这样的文件或目录'tmp/tree_merger -tmp_dest_dir-74tK3rvD.tmp/[app-name] /components/mixins/ui-listener.js'
似乎有趣的是,"mixins"目录嵌套在"components"目录下(因为Ember-CLI将这些目录放在同一级别),但这可能只是一个Brocoli构建步骤.无论如何,任何帮助将不胜感激.
我正在进行单元测试,感觉我做错了.我有一个'主'对象有很多关系
author: belongsTo('person', { async: true }),
title: attr('string'),
category: belongsTo('category', { async: true }),
impact: belongsTo('impact', { async: true }),
status: attr('string'),
createdDate: attr('moment'),
submittedDate: attr('moment'),
authorOrg: belongsTo('organization', { async: true }),
locations: hasMany('location', { async: true }),
audits: hasMany('audit', { async: true })
Run Code Online (Sandbox Code Playgroud)
每次我在单元测试及其相关项目的工作时间(person,category,impact),我有重现所有的needs,我的"主"对象有值.category当我只关心字符串的名称及其与'main'对象之间的关系时,我觉得我的位置单元测试不合适
// location/model-test.js
import {
moduleForModel,
test
} from 'ember-qunit';
moduleForModel('location', 'Location', {
// Specify the other units that are required for this test.
needs: …Run Code Online (Sandbox Code Playgroud) 我正在http://www.ember-cli.com/#ember-data上建议使用带有Ember CLI的http-mock .我理解CSP的基本概念,但我不了解它在Ember CLI应用程序中的配置.
如何配置我的应用程序以接受请求以localhost:4200/api/在开发期间避免这种情况:
Content Security Policy violation: {
"csp-report": {
"document-uri":"http://localhost:4200/products",
"referrer":"",
"violated-directive":"style-src 'self'",
"effective-directive":"style-src",
"original-policy":"default-src 'none'; script-src 'self' 'unsafe-eval' localhost:35729 0.0.0.0:35729; font-src 'self'; connect-src 'self' ws://localhost:35729 ws://0.0.0.0:35729 http://0.0.0.0:4200/csp-report; img-src 'self'; style-src 'self'; media-src 'self'; report-uri http://0.0.0.0:4200/csp-report;",
"blocked-uri":"",
"source-file":"chrome-extension://alelhddbbhepgpmgidjdcjakblofbmce",
"line-number":1,"column-number":20481,"status-code":200
}
}
Run Code Online (Sandbox Code Playgroud) 根据博客文章的ember-data版本1.0.0-beta.16,商店现在可以用作服务:
TweetComposerComponent = Ember.Component.extend({
store: Ember.inject.service()
});
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚如何qunit对这样的组件进行单元测试.我尝试过以下方法:
moduleForComponent('tweet-composer', {
needs: ['service:store']
});
Run Code Online (Sandbox Code Playgroud)
和:
moduleForComponent('tweet-composer', {
needs: ['store:main']
});
Run Code Online (Sandbox Code Playgroud)
当我做前者时,我得到一个错误Attempting to register an unknown factory: 'service:store',如果我做后者那么store就是undefined.
思考?
(我正在写一个ember-cli样式应用程序).
更新:
在ember-test-helpers repo中似乎存在一个未解决的问题.
在我等待这个修复的同时,我制作了一个可以作为一种间隙测量的辅助工具(coffeescript):
`import TestModuleForComponent from 'ember-test-helpers/test-module-for-component'`
`import { createModule } from 'ember-qunit/qunit-module'`
# This assumes the last argument, the callbacks, is present, although it
# does support the description being an optional …Run Code Online (Sandbox Code Playgroud) 每个google结果都与ArrayController排序有关.需要一个排序机制而不使用ArrayController.
有一个模型,其中有排序参数.就像说'sortOrder'作为模型中的一个属性(它将来自后端).
将使用#each渲染此模型,但这应该基于sortOrder属性而不是模型的ID属性进行迭代.
ember-cli ×10
ember.js ×9
ember-data ×2
javascript ×2
asp.net ×1
ember-qunit ×1
favicon ×1
http-mock ×1
unit-testing ×1