这一切都在标题中,真的.
在Babel文档中,页面上有以下描述babel-runtime的行
此转换器的另一个目的是为您的代码创建沙盒环境.诸如Promise,Set和Map之类的内置函数别名为core-js,因此您可以无缝地使用它们,而无需全局污染的polyfill.
该填充工具就是这样,这是包括了单独的JavaScript文件,其中衬层一些丢失的东西.
我使用我的构建工具(webpack)测试了polyfill与使用babel-runtime的比较,当我使用babel-runtime时,我的文件略小一些.
我不是在开发一个库或插件,只是一个Web应用程序,也不关心被污染的全局范围.了解这一点,除了稍微小一点的最终文件大小,在使用运行时通过polyfill还有其他任何实际好处或要点吗?
我正在使用Apache 2.4,我设置了两个虚拟目录.一个需要SSL,另一个重定向到它.
如果用户尝试在https://www.derp.com/derp没有/ derp存在的情况下访问,则会正确获取404.但是当用户访问时http://www.derp.com/derp,Apache会错误地将用户重定向到https://www.derp.comderp,删除路径和域名之间的斜杠.
我不知道是什么原因引起的.
以下是我的虚拟主机的设置.
<VirtualHost *:443>
ServerAdmin derp@derp.com
ServerName www.derp.com
ServerAlias derp.com
DocumentRoot "C:\Users\derp\Documents\Web Projects\derp"
SSLEngine on
SSLCertificateFile "C:\Apache24\certs\cert.cer"
SSLCertificateKeyFile "C:\Apache24\certs\key.key"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin derp@derp.com
ServerName www.derp.com
ServerAlias derp.com
Redirect permanent / https://www.derp.com/
</VirtualHost>
<Directory "C:\Users\derp\Documents\Web Projects\derp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
SSLRequireSSL
</Directory>
Run Code Online (Sandbox Code Playgroud)
为什么Apache会这样表现?
红利问题:重定向应该在我的虚拟主机定义中处理,还是应该在网站的物理目录中的.htaccess文件中处理?
编辑:
我正在启动一个Laravel项目,默认情况下公用文件夹确实包含.htaccess文件,所以这是那个人:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
编辑二: …
我到处都是混合信号.
我是否使用&符号通过引用传递变量?
以下链接似乎告诉我它已被弃用,不再需要:http:
//gtk.php.net/manual/en/html/tutorials/tutorials.changes.references.html
但像这样的线程让我想知道:
呼叫时间传递引用已被弃用?
PHP和&符号
让我以我的问题为例.
如果我使用PHP 5.5.5创建一个函数:
function recurring_mailer_form($form, $form_state)
{
}
Run Code Online (Sandbox Code Playgroud)
它是否相同:
function recurring_mailer_form($form, &$form_state)
{
}
Run Code Online (Sandbox Code Playgroud)
?
例如,我有一个产品,我有一个BaseProduct.
在产品的模型中,我指定了以下内容:
//In class Product
public function BaseProduct()
{
return $this->belongsTo("BaseProduct", "BaseProductId");
}
Run Code Online (Sandbox Code Playgroud)
在BaseProduct中,我指定了以下关系:
//In class BaseProduct
public function Products()
{
return $this->hasMany("Product", "ProductId");
}
Run Code Online (Sandbox Code Playgroud)
如果我选择产品,如下:
$Product::first()
Run Code Online (Sandbox Code Playgroud)
我可以通过执行以下操作来获取BaseProduct:
$Product::first()->BaseProduct()->get();
Run Code Online (Sandbox Code Playgroud)
而不是从中得到结果的数组,我如何得到ModelBaseProduct,所以我可以获得BaseProduct的所有子项,这意味着所有具有与此BaseProduct相关的外键的产品.
我试过了BaseProduct()->all();,但它不是一个有效的方法.
编辑:
我创建了以下函数调用链 - 但它很糟糕.
return BaseProduct::find(Product::first()->BaseProduct()->getResults()['BaseProductId'])->Products()->getResults();
Run Code Online (Sandbox Code Playgroud)
最终编辑:
我在我的BaseProduct模型中犯了一个错误.在Products()函数中,我已经指定return $this->hasMany("Product", "ProductId");了ProductId应该在哪里BaseProductId.
在我修复之后,我可以成功使用:
Product::first()->BaseProduct->products;
Run Code Online (Sandbox Code Playgroud)
正如Sheikh Heera所解释的那样.
我不太确定为什么我的计算属性没有返回更新的值.
我有一个用户可以点击的选项列表,操作更新控制器的属性,即Ember对象.我有一个循环遍历对象的计算属性,查找具有该Ember对象属性的非空值的键,如果找到一个,则返回false,否则返回true.
这是东西:
App.SimpleSearch = Ember.Object.extend({
init: function() {
this._super();
this.selectedOptions = Ember.Object.create({
"Application" : null,
"Installation" : null,
"Certification" : null,
"Recessed Mount" : null,
"Width" : null,
"Height" : null,
"Heating" : null,
"Power" : null
});
},
selectedOptions: {},
numOfOptions: 0,
allOptionsSelected: function() {
var selectedOptions = this.get('selectedOptions');
for (var option in selectedOptions) {
console.log(selectedOptions.hasOwnProperty(option));
console.log(selectedOptions[option] === null);
if (selectedOptions.hasOwnProperty(option)
&& selectedOptions[option] === null) return false;
}
return true;
}.property('selectedOptions')
});
App.SimpleSearchRoute = Ember.Route.extend({
model: function() { …Run Code Online (Sandbox Code Playgroud) 如何在Ember.js中观察多个查询参数,使用query-params-new,而不显式列出每个查询参数observes(),或property().
假设我有以下查询参数列表:
queryParams: [
'first',
'second',
'third',
'fourth',
'fifth',
'sixth',
'seventh',
'eighth',
'ninth',
'tenth'
],
first: null,
second: null,
third: null,
fourth: null,
fifth: null,
sixth: null,
seventh: null,
eighth: null,
ninth: null,
tenth: null
Run Code Online (Sandbox Code Playgroud)
我想在控制器中有一个方法来观察所有这些属性,但不必列出它们,例如:
something: function() {
...
}.property('first', 'second', 'third', ...)
Run Code Online (Sandbox Code Playgroud)
编辑:
我循环遍历queryParams数组,并在相应的属性上为每个数组设置一个观察者,如下所示:
init: function () {
this._super();
var queryParams = this.get('queryParams');
var self = this;
queryParams.forEach(function (param) {
self.addObserver(param, self, 'updateSelectedOptionsIfQueryParamsChange');
});
},
Run Code Online (Sandbox Code Playgroud)
它按预期工作.有没有更好的方法来做到这一点,或者这是正确的吗?
在实例化或为特定路由重新初始化控制器时,是否应该使用事件或挂钩来捕获控制器?
我已经尝试过init()- 但是我的控制器只在应用程序的生命周期中实例化一次,但根据路径支持多种模型.我需要捕获的是当控制器的模型发生变化时,或者在实例化后路由发生变化时的某个时刻.
我也尝试过设置一个计算属性,但它并不合适,因为我需要一个事件来在模型改变时触发一个函数 - 不仅仅是在调用属性时.
非常感谢任何帮助.
编辑:啊哈!我完全看了一下这个事实,我可以设置observes()我的功能,以便在模型更改时触发它.
所以,我的答案是做以下事情:
dependency: function() {
console.log('the model has changed');
//...other stuff...
}.observes('model')
Run Code Online (Sandbox Code Playgroud) 我应该使用:
this.get('controller').get('simpleSearch').get('selectedOptions').get('height')
Run Code Online (Sandbox Code Playgroud)
或者
this.get('controller.simpleSearch.selectedOptions.height')
Run Code Online (Sandbox Code Playgroud)
我认为第一个是...冗长。有什么理由不使用第二种方法吗?
我有以下型号:
Product
BaseProduct
BaseCode
Series
Run Code Online (Sandbox Code Playgroud)
他们每个人都是一个独立的实体,但他们是相关的.
Product有一个外键BaseProduct,BaseProduct有一个外键BaseCode和BaseCode一个外键Series.
我在BaseCode模型中指定了一个方法,因此我可以选择Products与该特定内容相关的所有方法BaseCode:
public function Products()
{
return $this->hasManyThrough('Product', 'BaseProduct', 'BaseCodeId', 'BaseProductId');
}
Run Code Online (Sandbox Code Playgroud)
BaseCodeId是BaseCode和BaseProduct那个指向那个PK 的FK的PK,并且BaseProductId是PK的BaseProduct,在Product表中,有一个指向它的FK.
这一切都很好,对我来说只是花花公子.
我想更进一步,并在我的Series模型中定义如下内容:
public function Products()
{
//It's here that I'd have no idea what to do - is there something like a three-level deep "hasManyThroughThrough" or something?
return $this->BaseProducts()-> /* …Run Code Online (Sandbox Code Playgroud) 在检查从服务器下载JavaScript文件的请求时,我发现了区别.我只是想看看HTML中的链接是什么样的,但当我检查检查器时,我找不到任何JavaScript的引用.当我检查来源时,他们肯定在那里.
您可以在此处查看示例:http://todomvc.com/architecture-examples/angularjs/#/
我似乎无法弄清楚为什么.
这是Firebug的检查员:

这是从源头查看它:

还有一些元素属性似乎在两者之间消失.
有人可以解释原因吗?
编辑:
这是源代码的完整标记:
<!doctype html>
<html lang="en" data-framework="angularjs">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>AngularJS • TodoMVC</title>
<link rel="stylesheet" href="bower_components/todomvc-common/base.css">
<style>[ng-cloak] { display: none; }</style>
</head>
<body ng-app="todomvc">
<ng-view />
<script type="text/ng-template" id="todomvc-index.html">
<section id="todoapp" ng-controller="TodoCtrl">
<header id="header">
<h1>todos</h1>
<form id="todo-form" ng-submit="addTodo()">
<input id="new-todo" placeholder="What needs to be done?" ng-model="newTodo" autofocus>
</form>
</header>
<section id="main" ng-show="todos.length" ng-cloak>
<input id="toggle-all" type="checkbox" ng-model="allChecked" ng-click="markAll(allChecked)">
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list">
<li ng-repeat="todo …Run Code Online (Sandbox Code Playgroud)