我在html中有一个锚标记元素,如:
<a href="javascript:handleEvent(this, 'abc')"></a>
Run Code Online (Sandbox Code Playgroud)
现在在javascript函数中,我写了:
function handleEvent(sourceElement, txt) {
console.log(sourceElement);
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,安慰元素将成为窗口.我尝试了sourceElement.document.activeElement,但它似乎不适用于chrome,它将作为body元素出现.
我无法将锚标记的结构更改为'onClick'函数,因为这来自其他一些来源.有没有办法在这种情况下找到调用元素?
我正在尝试使用 Koa.js,并检查了以下用于路由请求的模块: 1. koa-route 2. koa-mount
当我在 google 中查看他们的 github 页面/教程时,这些示例看起来几乎相似,但略有不同。
对于 koa 路线:
var route = require('koa-route');
app.use(route.get('/', index));
//functions to handle the request
function* index(){
this.body = "this should be home page!";
}
Run Code Online (Sandbox Code Playgroud)对于 koa-mount:
//syntax to add the route
var mount = require('koa-mount');
var a = koa();
app.use(mount('/hello', a));
//functions to handle the request
a.use(function *(next){
yield next;
this.body = 'Hello';
});
Run Code Online (Sandbox Code Playgroud)在我看来唯一的区别是 mount 需要一个中间件来处理请求,而 route 需要一个生成器来处理请求。
我很困惑何时使用什么以及何时使用两者(在某些教程中看到过)?
我正在尝试使用以下命令在生产模式下运行rails(不太了解它):
rails server -e production
Run Code Online (Sandbox Code Playgroud)
但是我在控制台和丑陋的页面中收到这些错误而没有加载css:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://10.20.200.199:3000/".
(index):1 Refused to execute script from 'http://10.20.200.199:3000/javascripts/application.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
(index):1 Refused to execute script from 'http://10.20.200.199:3000/logins/plugins.js?v=1' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Run Code Online (Sandbox Code Playgroud)
这种情况发生在我们正在使用的所有脚本中.
有人可以帮我解决这里可能出错的问题.
提前致谢.
这是一个简单的下拉菜单,应该仅在外部单击时关闭。它曾经在早期版本(0.13)中工作。
难道我做错了什么。不想采取像停止传播和防止违约这样的解决办法。这是我最后的手段。
下面是一个简单下拉列表的 plunkr:
http://plnkr.co/edit/A2vDHb43PThalcHAhLkJ?p=preview
<span class="dropdown" uib-dropdown auto-close="outsideClick">
<a href="javascript:void(0);" class="dropdown-toggle" uib-dropdown-toggle>
Click me for a dropdown, yo!
</a>
<ul class="dropdown-menu">
<li>Element 1</li>
<li>Element 2</li>
</ul>
</span>
Run Code Online (Sandbox Code Playgroud)