草庐IT

parent_type

全部标签

javascript - 从 Webkit 通知返回给 parent

我正在使用webkitNotifications和createHTMLNotification等在Chrome(Windows)中成功创建通知。现在我真的很想让通知窗口与创建通知的选项卡/窗口(是规范的一部分)进行通信(或至少将焦点设置到)。我意识到此功能仍处于早期阶段,但我想也许有人知道办法。我试过了:window.opener.focus();从通知窗口,但没有用。这个页面...http://www.thecssninja.com/javascript/web-notifications说...“如提案中所述,使用window.opener.focus()将焦点带回调用通知的窗口,

javascript - 单元测试 : simulate the click event of child component in parent using enzyme

我有一个父组件和一个只是“标签”元素的子组件。当我点击子元素时,我需要调用父组件中的函数。我希望它被调用,但状态没有改变,当我看到覆盖文件时,函数没有被调用。**更新:**该代码适用于开发。只是单元测试失败了。这是我的父组件父类.jsexportdefaultclassParentextendsComponent{constructor(props){super(props)this.state={clickedChild:false}this.handleChildClick=this.handleChildClick.bind(this)}handleChildClick(inde

javascript - @types/react 找不到名称 'HTMLDialogElement'

我在使用typescript和@types/react时遇到了一个奇怪的构建问题。我有两个typescript配置文件:一个用于使用React的文件,一个用于不使用React的文件。在构建不使用React的项目部分时,我看到以下错误:node_modules/@types/react/index.d.ts(3508,58):errorTS2304:Cannotfindname'HTMLDialogElement'.node_modules/@types/react/index.d.ts(3508,78):errorTS2304:Cannotfindname'HTMLDialogElem

c# - 如何通过 SignalR 实现 'Who is typing' 功能?

我基本上是在我的网站上实现SignalR聊天。我已经可以向所有连接的用户发送消息,现在我希望添加“谁在输入”功能。我正在尝试将它添加到$('#message').keypress函数中,它可以工作,但现在我无法向用户发送消息。我做错了什么?移除$('#message').keypress后可以发送消息没有删除$('#message').keypress无法发送消息我的html{脚本如下:$(function(){//Referencetheauto-generatedproxyforthehub.varchat=$.connection.chatHub;//Createafunctio

javascript - react .js : attach event from parent to children

如下例所示,我希望MyComponent动态地将“onClick”事件附加到它的子组件。onClick事件应该触发alertView,它应该能够调用被点击的元素方法“getValue”。JSFiddle:http://jsfiddle.net/2g638bp8/如何做到这一点?谢谢varMyComponent=React.createClass({alertValue:function(){//RETRIEVETHECHILDHEREalert(child.getValue());},render:function(){varchildren=React.Children.map(th

javascript - react .createElement : type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object

预计我应该能够导出我的App组件文件并将其导入到我的index.js中。结果出现以下错误React.createElement:typeisinvalid--expectedastring(forbuilt-incomponents)oraclass/function(forcompositecomponents)butgot:object我的index.jsconstReact=require('react');constReactDOM=require('react-dom');constApp=require('./components/App');require('./inde

javascript - Service Worker 注册错误 : Unsupported MIME type ('text/html' )

我正在使用create-react-app用express服务器。create-react-app有一个预配置的ServiceWorker,可以缓存本地Assets(https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)。当我尝试在我的服务器上发布时遇到的问题是service-worker.js文件可用,但是当我尝试注册它时,我的浏览器控制台出现错误。在Firefox上,我遇到了这个错误

javascript - Sequelize : Include.,其中通过 'parent' 模型属性进行过滤

我有两个相关的模型,Catalog和ProductCategory。后者有一个组合的PK,'id,language_id'。以下是简化的模型:varCatalog=sequelize.define("Catalog",{id:{type:DataTypes.INTEGER,primaryKey:true,autoIncrement:true},user_id:{type:DataTypes.INTEGER,allowNull:false},product_category_id:{type:DataTypes.STRING(7)},language_id:{type:DataTypes

javascript - Chrome 扩展 : how to pass ArrayBuffer or Blob from content script to the background without losing its type?

我有这个内容脚本,它使用XHR下载一些二进制数据,稍后发送到后台脚本:varself=this;varxhr=newXMLHttpRequest();xhr.open('GET',url);xhr.responseType='arraybuffer';xhr.onload=function(e){if(this.status==200){self.data={data:xhr.response,contentType:xhr.getResponseHeader('Content-Type')};}};xhr.send();...later...sendResponse({data:se

Angular 2 : getting RouteParams from parent component

如何从父组件获取RouteParams?App.ts:@Component({...})@RouteConfig([{path:'/',component:HomeComponent,as:'Home'},{path:'/:username/...',component:ParentComponent,as:'Parent'}])exportclassHomeComponent{...}然后,在ParentComponent中,我可以轻松获取用户名参数并设置子路由。Parent.ts:@Component({...})@RouteConfig([{path:'/child-1',com