我有以下代码(<button id="7">我的HTML 中有一个代码):
(function() {
'use strict';
document.getElementById(7).addEventListener("click", function(){
console.log('clicked');
})
console.log('before');
document.getElementById(7).click();
console.log('after')
}());
Run Code Online (Sandbox Code Playgroud)
当这在Firefox 41控制台中运行时,我原以为
之前
点击
之后
因为代码将同步运行,然后在完成脚本后响应事件队列上的click事件.相反,我得到了
以前
点击
后
这表明事件正在同步处理?
本质上是我想要的
let schema = {
name: null,
lastname: null
}
let values = {
name: "John",
unwanted: "haxor"
}
Run Code Online (Sandbox Code Playgroud)
最终出现在:
console.log(sanitized); // {name: "John", lastname: null}
Run Code Online (Sandbox Code Playgroud)
-
使用Object.assign(schema, values)最终会带来不必要的价值。
有没有简单的方法?
编辑:我应该补充,这是为了避免使用像lodash或下划线之类的库,因此,如果解决方案过于复杂,则它们将是首选解决方案。
我设置了两条路线
Route::get('/bugreport', 'SomeController@create')
->middleware('signed')
->name('bugreport');
Route::get('/getlink', function() {
return dd(\URL::signedRoute('bugreport', ['data' => 3]));
});
Run Code Online (Sandbox Code Playgroud)
当APP_ENV=local我可以访问时,请/getlink点击生成的URL并显示它。当APP_ENV=production(更改变量时实际物理环境未更改)时,此命令不再起作用...说明无效签名。有什么建议么?
更新:
我们确实有...可能是其中一部分
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if (!config('app.is_local')) {
URL::forceScheme('https');
}
}
Run Code Online (Sandbox Code Playgroud)
注意:删除上面的代码实际上可以解决此问题,但随后会中断登录等操作,因此需要了解原因,否则这不是选项:(。
更新更新:
环境是heroku,.htaccess具有(根据https://help.heroku.com/J2R1S4T8/can-heroku-force-an-application-to-use-ssl-tls)
#### FORCE SSL
## see - https://help.heroku.com/J2R1S4T8/can-heroku-force-an-application-to-use-ssl-tls
RewriteCond %{HTTP_HOST} !=localhost
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# …Run Code Online (Sandbox Code Playgroud) 错误
调用 shopify ajax api 时,我在开发人员工具控制台中收到错误消息。
Uncaught SyntaxError: Unexpected token :
在 javascript 控制台中单击此错误会奇怪地显示有效 JSON 的响应:
{
"id":19728251846714,
"properties":null,
"quantity":1,
"variant_id":19728251846714,
"key":"19728251846714:f1a55a69aed71e7c10ca53fd3549edda",
"title":"Ritual Petalos de rosas y vino tinto - Obispado",
"price":139900,
"original_price":139900,
"discounted_price":139900,
"line_price":139900,
"original_line_price":139900,
"total_discount":0,
"discounts":[],
"sku":"",
"grams":0,
"vendor":"Casa Azul Spa",
"taxable":false,
"product_id":1959512244282,
"gift_card":false,
"url":"\/products\/ritual-petalos-de-rosas-y-vino-tinto?variant=19728251846714",
"image":"https:\/\/cdn.shopify.com\/s\/files\/1\/0087\/2267\/7818\/products\/PETALOS_DE_ROSAS_Y_VINO_TINTO.jpg?v=1538589224",
"handle":"ritual-petalos-de-rosas-y-vino-tinto",
"requires_shipping":false,
"product_type":"",
"product_title":"Ritual Petalos de rosas y vino tinto",
"product_description":"\u0026lt;!--\ntd {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}\n--\u003eRitual Pétalos de Rosas y Vino tinto, Exquisito masaje que ofrece bienestar, relajación e hidrata la piel. …Run Code Online (Sandbox Code Playgroud)