这是情况:有一个网站,它属于客户端,所以它不在我的域名上,比如说client.com.
在这个网站上有一个iframe,这iframe是一个简单的js代码,它加载另一个js(client.js) - 这个代码在我的域上.
我需要做的是获取iframe所在页面的确切网址.所以现在我试图弄清楚之间的区别document.referrer和window.parent.location.href没有运气.
两者都给了我我需要的东西,但我无法意识到什么更可靠?是否存在一种情况,一种情况会起作用而另一种情况不会发生?
这是我正在努力工作的代码(角度5):
import { Component, ViewChild, TemplateRef, ViewContainerRef } from '@angular/core';
@Component({
selector: 'vcr',
template: `
<template #tpl>
<h1>ViewContainerRef</h1>
</template>
<div>Some element</div>
<div #container></div>
`,
})
export class VcrCmp {
@ViewChild('container', { read: ViewContainerRef }) _vcr;
@ViewChild('tpl') tpl: TemplateRef<any>;
constructor(
private viewContainerRef: ViewContainerRef
) {
}
ngAfterViewInit() {
console.info(this.viewContainerRef);
console.info(this._vcr);
this._vcr.createEmbeddedView(this.tpl);
this.viewContainerRef.createEmbeddedView(this.tpl);
}
}
Run Code Online (Sandbox Code Playgroud)
问题是我有这个(templateRef.createEmbeddedView is not a function)错误而且不太明白为什么.
此代码基于此示例https://netbasal.com/angular-2-understanding-viewcontainerref-acc183f3b682,所以我想它应该可行.
我究竟做错了什么?
我有一个反应组件,它有两个子组件,如下所示:
import {Child1} from './child1';
import {Child2} from './child2';
...
return (
<>
<Child1 />
<Child2 />
</>
)
Run Code Online (Sandbox Code Playgroud)
我正在使用 Reacttesting-library和创建的应用程序create react app,而不是弹出。我想在我的单元测试中模拟它们,因为它们有自己的测试,所以我试图:
jest.mock('./child1', () => 'some mocked string');
jest.mock('./child1', () => 'some mocked string');
Run Code Online (Sandbox Code Playgroud)
但是当我使用它渲染它时,import { render } from '@testing-library/react';我看到以下内容Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined。
这是为什么?我如何模拟这些组件?
我想为我的网络应用程序实现用户的活动记录(php+ js+ mysql).
以前,我用过这个appoach:
activity使用该临时表中的用户ID 在表中插入行的所有表创建触发器现在我真的不想在数据库中加入太多逻辑,所以我的问题是:最佳实践是什么?我应该继续使用所描述的方法,还是应该使用其他方法?
编辑1
我已经看到了这个问题,但我很想将所描述的方法与答案中的方法进行比较.
编辑2
为什么我需要日志:如果出现问题,我需要知道应该责怪哪个用户=)
日志必须包含已更改的数据和新数据,以查看实际更改的内容.
不会有很多用户因为它是一个企业应用程序,我们的公司不是那么大.
主要问题是我应该在哪里放置日志逻辑:数据库或应用程序(php后端)级别?
我有一个奇怪的问题:当使用Firebug Lite for Chrome时,有时悬停不起作用.
我得到了什么:div像这样:
<div class="editWindow">
<ul>
<li id="edCha" onclick="channels.add()">
????????????? ?????
</li>
<li id="delCha" onclick="channels.chanLink()">
?????????? ???????
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
这个CSS:
.editWindow li:hover, .chooseAction li:hover {
background: #369;
color: white;
cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
当我第一次打开页面然后激活Firebug时,它看起来都像这样:

但是,如果我首先激活Firebug然后打开此页面,则悬停只是不起作用.我在Firebug控制台中看不到任何错误,并且没有像这样的悬停效果(鼠标指针在那里,相信我):

我只在Chrome(Firefox运行良好)中遇到过这个问题,无论是在Win7还是在Linux(Mint 14)上.
原因是什么?我糊涂了.
当使用Force element state -> :hover的开发工具菜单,悬停风格的作品.
我添加onmouseover="alert('test');"了其中一个li元素.在第二种情况下,alert甚至没有被召唤!
所以,我有一份文件:
var doc = new PDFDocument;
文档告诉我PDFKit文档的第一页是自动添加的,所以不需要手动添加它.但是我怎么能把它当成风景呢?
这个
doc.addPage({
size: 'LEGAL',
layout: 'landscape'
});
Run Code Online (Sandbox Code Playgroud)
工作,但添加另一页.
我有一个由graphviz工具制作的无向图(现在我正在使用sfdp):
digraph structs {
node [shape=Mrecord, URL="index_new.php?object=\N&overlap=false"];
overlap = orthoxy;
bgcolor=transparent;
splines=true;
rankdir=TB;
node [fontname="Arial", fontsize=30, style=filled, fillcolor=chartreuse1, image="../common/img/monitor.png"]struct_swbposad91 [label = "sw-bposad9-1\n192.168.17.141\nC2960 "];
node [fontname="Arial", fontsize=30, style=filled, fillcolor=chartreuse1, image="../common/img/monitor.png"]struct_swmedikov5fan [label = "sw-medikov5-fan\n192.168.34.134\n "];
node [fontname="Arial", fontsize=30, style=filled, fillcolor=chartreuse1, image="../common/img/monitor.png"]struct_swlevash131 [label = "sw-levash13-1\n192.168.16.165\nC2960 "];
node [fontname="Arial", fontsize=30, style=filled, fillcolor=deepskyblue]struct_swpolevsabirov45a [label = "sw-polevsabirov45a\n192.168.18.182\nS2300 "];
...lots of lines goes here...
struct_swkazan71:f450212->struct_swbmorsk181:f450213 [weight=1.2, dir=both, color=black, penwidth=5, arrowhead="empty", arrowtail="odot"];
struct_swmikh171:f450222->struct_swbotk151:f450223 [weight=1.2, dir=both, color=black, penwidth=1, arrowhead="empty", arrowtail="odot"];
...lots of lines goes here...
Run Code Online (Sandbox Code Playgroud)
这里是完整的代码:http …
这是我试图用来创建触发器的代码:
-- Dumping structure for trigger kavanga_lead.click_links_insert
DROP TRIGGER IF EXISTS `click_links_insert`;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='';
DELIMITER //
CREATE TRIGGER `click_links_insert` AFTER INSERT ON `click_links` FOR EACH ROW BEGIN
INSERT INTO actions_log
(
`uid`,
`table`,
`action`,
`new`
)
VALUES
(
@user_id,
'click_links',
'insert',
concat(NEW.id ,'|', NEW.`contents`, '|', NEW.channel_id, '|', NEW.name, '|', NEW.hidden, '|', if(NEW.prefix_id is null,'',NEW.prefix_id) '|', if(NEW.postfix_id is null,'',NEW.postfix_id))
);
END//
DELIMITER ;
SET SQL_MODE=@OLD_SQL_MODE;
Run Code Online (Sandbox Code Playgroud)
我不断收到错误 (1583) Incorrect parameters in the call to concat。如果我不使用if(NEW.prefix_id is null,'',NEW.prefix_id)而只使用NEW.prefix_id …
这是代码:
<label onclick="event.stopPropagation(); alert(event.target.innerHTML);">
<button>
button
</button>
<span>
span
</span>
</label>
Run Code Online (Sandbox Code Playgroud)
(和小提琴:http://jsfiddle.net/YsYKq/1/)
如果一个点击按钮,仅button是警告,但在跨时-无论是span和button发出警报-这样的onclick函数被调用两次.
我怎么能阻止这个?我只需要onclick被召唤一次.
我正在尝试在php中为我的任务实现某种"多处理".任务是检查网络中每个设备的状态.
为此,我决定使用循环exec,它的工作原理.但我不知道它是否正常工作:
$command = "php scan_part.php $i > null &";
exec($command);
Run Code Online (Sandbox Code Playgroud)
这可以scan_part.php根据需要多次调用,但问题是:我如何计算所有scan_part.php执行所需的时间?
拜托,帮助我,我被困住了!