在 chrome 测试版中,我的一个应用程序出现以下错误,
无法在资源“ http://localhost:8000/assets/vendor-2d2d91b98d3771c414a0b039e0b4d8c1.js ”的“integrity”属性中找到有效的摘要,计算出的 SHA-256 完整性为“RtMfPvtdjkEbZERLg=‘RtMfPvtdjkEbZERLg’ 该资源已被阻止。
正如github 线程指出它已修复,但我收到此错误ember-cli-2.14.1,"ember-cli-sri": "^2.1.0",因此我将包含integrity=''. 我想知道,这种变化有什么后果吗?
我有两个模型员工和 empdetails
//employee model
import DS from 'ember-data';
export default DS.Model.extend({
empId : DS.attr(),
password : DS.attr(),
email : DS.attr(),
empdetails : DS.belongsTo("empdetails")
});
//empdetails model
import DS from 'ember-data';
export default DS.Model.extend({
firstName : DS.attr(),
lastName : DS.attr(),
dateOfJoining: DS.attr(),
employee : DS.belongsTo("employee")
});
Run Code Online (Sandbox Code Playgroud)
我使用 RESTAdapter 进行 REST 调用。
//serializer
import DS from 'ember-data';
export default DS.JSONSerializer.extend({
});
Run Code Online (Sandbox Code Playgroud)
当我尝试为员工发出获取请求时,出现以下错误
请检查您的序列化程序并确保它将关系负载序列化为 JSON API 格式。错误:断言失败:遇到了一个没有属于属于关系的类型的关系标识符 'empdetails' on ,需要一个类型为 'empdetails' 的 json-api 标识符,但找到了 '{"id":"1","firstName":"xxx "}
我从我的后端得到以下 JSON
[
{
"id": 1,
"email": …Run Code Online (Sandbox Code Playgroud) 在 Ember JS 中,假设我有一个定义如下的组件(HBS/JS)
parent.hbs
{{longclaw-sword attack=(action swing)}}
Run Code Online (Sandbox Code Playgroud)
app/components/longclaw-sword.js
export default Ember.Component.extend({
click() {
this.attack();
}
});
Run Code Online (Sandbox Code Playgroud)
使用this.attack()V/s调用关闭操作有什么区别
this.attr.attack()吗?
在哪些情况下使用“attr”?它可以用于参考正常属性还是仅用于操作?
在我的应用程序中,我将EmberJS添加到已加载jQuery的页面中.所以我不需要ember-cli来包含jQuery.
我想创建具有我需要从REST API获取的设置的全局对象.我需要向REST API发出一个请求并获取设置,之后我想从任何控制器和任何模板访问这些设置.你有什么建议,这个问题的最佳实践是什么?
我试图在我的应用程序中包含一个模块来自其中一个测试.甚至可以这样做吗?我只能在'tests'目录中包含一个模块.我一直得到臭名昭着的"找不到模块"错误.
http://localhost:4200/assets/test-support.js:5578:16: Could not find module d3graph/app/controllers/index imported from d3graph/tests/unit/utils/graph-helper-test
这是我的测试代码:
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
import helper from '../../../app/anything/anywhere'; // <- THIS LINE FAILS
moduleFor('util:graph-helper', 'Graph Helper', {
beforeEach: () => initialize()
});
function initialize() { /* something */ };
test('test desc', function(assert) {
var testObj = this.subject();
// test logic follows
});
Run Code Online (Sandbox Code Playgroud)
我确实尝试了对模块路径的各种修改,包括来自root的绝对路径,我甚至试过通过'require()',但唉没有成功.请帮忙.
我需要在我的Ember-CLI应用程序中拥有动态更改路径的图像,即 <img src="my_dynamic_path">.
但是,因为Ember为所有图像添加了一个cachebusting字符串,所以我不能这样做.
有没有办法禁用cachebusting字符串,或某些找到cachebusted图像名称的URL的函数,或者不受此行为影响的文件夹?
我需要在model钩子后设置一个控制器属性.我可以想到两种方法:
model(params) {
return this.store.findRecord('user', 1);
},
afterModel(model, transition) {
model.get('profile').then(profile => {
this.set('profile', profile);
});
},
setupController(controller, model) {
controller.set('model', model);
controller.set('profile', this.get('profile'));
},
Run Code Online (Sandbox Code Playgroud)
另一种方法.即跳过setupController:
model(params) {
return this.store.findRecord('user', 1);
},
afterModel(model, transition) {
model.get('profile').then(profile => {
this.controller.set('profile', profile);
});
},
Run Code Online (Sandbox Code Playgroud)
两者似乎都有效.
两种方法都有任何额外的优点/缺点吗?显然,后者更短.但是在afterModel钩子中设置控制器属性是否感觉"干净" ?
编辑:之间的关系/关联user和profile是async.
我刚刚将我的Ember应用程序升级到最新版本,但在测试其功能时,某些操作无效.我之前在旧版本中运行良好的代码如下.
export default Ember.Controller.extend({
needs: 'sales-order',
actions: {
showModal: function(mode){
this.get('controllers.sales-order').send('showModal', mode);
}
}
});
Run Code Online (Sandbox Code Playgroud)
看起来" 需求 "是折旧的.
我正在尝试使用更新的软件包重建项目,但遇到此错误:
[folatt@ArkOS-Dev genesis]$ ember build
cleaning up...
Build failed.
The Broccoli Plugin: [SourceMapConcat: Concat: Vendor /assets/vendor.js] failed with:
Error: ENOENT: no such file or directory, open '/home/folatt/workspace/arkos/genesis/tmp/source_map_concat-input_base_path-xZBOP47K.tmp/bower_components/ember-cli-shims/app-shims.js'
at Object.fs.openSync (fs.js:583:18)
at Object.fs.readFileSync (fs.js:490:33)
at SourceMap.addFile (/home/folatt/workspace/arkos/genesis/node_modules/fast-sourcemap-concat/lib/source-map.js:75:31)
at /home/folatt/workspace/arkos/genesis/node_modules/broccoli-concat/concat.js:200:16
at Array.forEach (native)
at Concat.<anonymous> (/home/folatt/workspace/arkos/genesis/node_modules/broccoli-concat/concat.js:198:24)
at /home/folatt/workspace/arkos/genesis/node_modules/fast-sourcemap-concat/lib/source-map.js:393:12
at initializePromise (/home/folatt/workspace/arkos/genesis/node_modules/rsvp/dist/rsvp.js:589:5)
at new Promise (/home/folatt/workspace/arkos/genesis/node_modules/rsvp/dist/rsvp.js:1077:31)
at SourceMap.end (/home/folatt/workspace/arkos/genesis/node_modules/fast-sourcemap-concat/lib/source-map.js:380:10)
The broccoli plugin was instantiated at:
at Concat.Plugin (/home/folatt/workspace/arkos/genesis/node_modules/broccoli-plugin/index.js:7:31)
at new Concat (/home/folatt/workspace/arkos/genesis/node_modules/broccoli-concat/concat.js:38:10)
at module.exports (/home/folatt/workspace/arkos/genesis/node_modules/broccoli-concat/index.js:26:10)
at EmberApp.concatFiles (/home/folatt/workspace/arkos/genesis/node_modules/ember-cli/lib/broccoli/ember-app.js:392:10)
at EmberApp._concatFiles (/home/folatt/workspace/arkos/genesis/node_modules/ember-cli/lib/broccoli/ember-app.js:405:15)
at EmberApp.javascript …Run Code Online (Sandbox Code Playgroud)