我想知道如何在 Ember-CLI 插件中使用 SASS?
我在/app/styles文件夹中有我的样式,但我不确定那是放置它们的正确位置。我已经broccoli-sass安装在我的插件项目中,当我将我的文件夹包含在/tests/dummy/app/styles/app.scss.
@import 'app/styles/app.scss';
但我不知道如何编译 scss 文件以进入 .scss 文件/dist/assets/vendors.css,这是使用此插件的项目加载的文件。
我正在使用 ember-cli 开发一个应用程序,它需要使用 ProxyPass 向服务器发送 http 请求。
我的服务器如下所示: subdomain.domain.com/api/clients/users 和 Ember-cli 默认创建http://localhost:4200/
我尝试在我的 http.conf 中执行此操作:
ProxyPass /api/clients http://subdomain.domain.com/api/clients
Run Code Online (Sandbox Code Playgroud)
这对于http://localhost/api/clients工作正常,但我不知道如何使其与非标准端口(例如 4200)一起工作。
我也尝试创建一个 virtualHost 但它是相同的:
<VirtualHost *:4200>
ProxyPass /api/clients http://subdomain.domain.com/api/clients
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点 ?
[编辑]:我像这样设置我的 RESTAdapter :
var ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'api/clients'
});
Run Code Online (Sandbox Code Playgroud) 我正在开发一个简单的 Ember 应用程序,它从 API 检索所有语言字符串。我已经使用一种translate()方法设置了一个服务,并将该服务注入到一个帮助程序中。问题是我想使用它的属性在助手中不可用,因为当它被使用时,承诺还没有兑现。从服务加载后,如何访问助手中的属性?
服务(应用程序/服务/i18n.js):
export default Ember.Service.extend({
locales: null,
init() {
this._super();
Ember.$.getJSON('/api/recruiting/locales').then(function (response) {
this.set('locales', response.data);
}.bind(this));
},
translate(key) {
// This causes the problem: locales property has not been loaded yet at this point
return this.get('locales.' + key);
}
});
Run Code Online (Sandbox Code Playgroud)
助手(app/helpers/translate.js):
export default Ember.Helper.extend({
i18n: Ember.inject.service(),
compute(params/*, hash*/) {
var i18n = this.get('i18n');
return i18n.translate(params[0]);
}
});
Run Code Online (Sandbox Code Playgroud) 在使用ember new ietest --no-welcome和执行ember serve不修改任何代码的情况下创建新的应用程序后,Ember 应用程序在 Chrome 和 IE Edge 中加载良好,但在 IE 11 中无法加载并产生两个错误:
Syntax Error at vendor.js (64292,18)Expected Identifier at ietest.js (32,9)该页面是空白的,甚至没有显示“欢迎使用 Ember”。如果我离开,也会发生错误--no-welcome。在这种情况下,仓鼠页面不会出现。
余烬cli版本:3.1.2
操作系统:Windows 10
有任何解决这个问题的方法吗?也许我可以切换 IE11 中的设置?
我正在尝试编写自定义身份验证器,类似于文档中此示例中的身份验证器.目标是能够通过检索当前登录的用户session.user.
我正在使用Ember CLI,所以initializers/authentication.js我有
import Ember from 'ember';
var customAuthenticator = Ember.SimpleAuth.Authenticators.Devise.extend({
authenticate: function(credentials) {
debugger;
}
});
export default {
name: 'authentication',
initialize: function(container, application) {
Ember.SimpleAuth.Session.reopen({
user: function() {
var userId = this.get('user_id');
if (!Ember.isEmpty(userId)) {
return container.lookup('store:main').find('user', userId);
}
}.property('userId')
});
// register the custom authenticator so the session can find it
container.register('authenticator:custom', customAuthenticator);
Ember.SimpleAuth.setup(container, application, {
routeAfterAuthentication: 'landing-pages',
authorizerFactory: 'ember-simple-auth-authorizer:devise'
});
}
};
Run Code Online (Sandbox Code Playgroud)
当我尝试进行身份验证时,出现以下错误:
TypeError: Cannot read property 'authenticate' of undefined …Run Code Online (Sandbox Code Playgroud) 它可以通过这种方式在"正常"的Ember中完成:
App.Person = DS.Model.extend({
name: DS.attr('string')
});
App.Soldier = App.Person.extend({
rank: DS.attr('string')
});
Run Code Online (Sandbox Code Playgroud)
我怎样才能在Ember-cli中实现这一目标?我不知道如何访问原始类型的Person.
我想在ember-cli应用程序中包含一个favicon.我已将.ico图像放入/public/assests/img/,并能够将该图像包含在页面中.
根据这个问题,我走在正确的轨道上,但......
我喜欢哪里的favicon?通常我会说:
<link rel="icon" href="/assets/img/favicon.ico">
Run Code Online (Sandbox Code Playgroud)
在head一个html文件中.什么.hbs文件应该包含head?我是ember和ember-cli的新手,但我认为hbs文件只是HTML文件的一部分.我试图将link标记扔进application.hbs文件中,但这不起作用.我错过了什么?
设置:
ember new shop
cd shop
ember install:addon ember-cli-scaffold
ember generate scaffold product name:string available:boolean
ember generate adapter product
Run Code Online (Sandbox Code Playgroud)
我想使用http-mock但http://www.ember-cli.com/#ember-data告诉我这样做:
ember g http-mock products
Run Code Online (Sandbox Code Playgroud)
之后我使用此代码生成两个示例产品:
服务器/嘲笑/ products.js
module.exports = function(app) {
var express = require('express');
var productsRouter = express.Router();
productsRouter.get('/', function(req, res) {
res.send({
'products': [
{
id: "1",
name: 'Orange',
available: true
}, {
id: "2",
name: 'Apple',
available: false
}
]
});
});
[...]
Run Code Online (Sandbox Code Playgroud)
当我使用该命令ember server并浏览到http:// localhost:4200/products时,我什么也看不见.
我错过了什么?我还有什么可以开始或配置?
我有一些像这样的文本输入助手
{{input type="text" valueBinding="name" focus-out="focusOutName"}}
Run Code Online (Sandbox Code Playgroud)
我刚刚将Ember升级到1.11.0,现在得到这个弃用警告:
弃用:您尝试通过将valueBinding传递给视图助手来呈现视图,但不推荐使用此语法.你应该使用
value=someValue.
但是,在使用值时,它不受控制器的约束,value只需将文本设置为任何值即可.
我该如何正确绑定它?
我刚刚开始研究Ember.js引擎.有一点值得注意的是,对于我在引擎代码中所做的每一项更改,我都需要将其重新安装到主机应用程序中.没有实时重新加载,重建或任何此类.
有没有办法消除这种流动,因为它会大大减缓开发速度.
ember-cli ×10
ember.js ×8
ajax ×1
ember-data ×1
es6-promise ×1
favicon ×1
htmlbars ×1
promise ×1
proxypass ×1
sass ×1