草庐IT

page_type

全部标签

javascript - Chrome 扩展 : have an extension listen for an event on a page?

我有一个为我的网站制作的chrome扩展程序,目前我有一个扩展程序每分钟检查一次数据库以获取更新。是否可以让扩展程序监听实际页面上的事件?像这样this.trigger('sendUpdate',data)//thishappenedonthepagethis.on(sendUpdate,function(){//thisiswhatthechromeextensionlistensfor//dostuffwithdata}) 最佳答案 您需要添加一个content_script。content_script具有对DOM的完全访问权

javascript - 流: Dynamically generate string union types?

假设我有一个流类型Suit,我想将它组合成另一种名为Card的类型。//types.jstypeSuit=|"Diamonds"|"Clubs"|"Hearts"|"Spades";typeCard={...suit:Suit,...}与其直接在suit.js中对Suit字符串进行硬编码,不如根据JavaScript原语(数组)动态生成Suit类型?说...//constants.jsconstSUITS=['Diamonds','Clubs','Hearts','Spades'];通过这种方式,西装只需定义一次,并且可以在JavaScript结构中定义,该结构将在应用程序的其他部分中

javascript - Angular 2 : Type 'Subscription' is not assignable to type

我创建了一个非常小的应用程序来从json文件中获取国家并将其绑定(bind)到下拉列表。countries.jsonexportclassCountry{id:number;name:string;}factory.service.tsimport{Injectable}from'@angular/core';import{Http,Response}from'@angular/http';import{Observable}from'rxjs/Observable';import{Country}from'./shared/country';@Injectable()exportcl

javascript - "Resource interpreted as script but transferred with MIME type text/html."

很抱歉,如果这实际上是重复的,但我还没有设法找到我的问题的答案。我使用jQuery的$.getScript加载脚本。但它会导致以下错误:ResourceinterpretedasscriptbuttransferredwithMIMEtypetext/html.该问题仅在MacOS下的Safari中出现如果查看从服务器收到的header,它们包含Content-Type:application/x-javascript,所以我真的不明白问题出在哪里。 最佳答案 Resourceinterpretedasscriptbuttransf

javascript - 在呈现 `Page` 之前获取数据异步

在呈现Page之前获取数据异步的正确方法是什么?据我所知,Angular2建议使用@CanActivate装饰器。遗憾的是,这不适用于Ionic2,至少对我和others无效。显然Ionic2使用@CanActivate装饰器做了一些事情,see但它没有记录,我无法弄清楚它到底做了什么。尽管如此thisguy指出无论如何都应该使用IonicsViewStates,因为ionics缓存。他的示例如下所示:onPageWillEnter(){returnthis._service.getComments().then(data=>this.comments=data);}看起来他希望Ion

javascript - typescript TS7015 : Element implicitly has an 'any' type because index expression is not of type 'number'

我在Angular2应用程序中遇到此编译错误:TS7015:Elementimplicitlyhasan'any'typebecauseindexexpressionisnotoftype'number'.导致它的代码是:getApplicationCount(state:string){returnthis.applicationsByState[state]?this.applicationsByState[state].length:0;}但这不会导致此错误:getApplicationCount(state:string){returnthis.applicationsBySt

javascript - Vue.js : Best way to implement MPA(Multi page app) in laravel

我找了好久了,还是没找到。在Laravel中实现VueMPA架构的最佳方法和实践是什么。搜索了很多。但是没有任何东西可以给你一个清晰的想法。您的回答会有很大帮助,请简短。回答这个问题也很有帮助:只使用laravel作为数据API并保留Vue是个好主意吗与Laravel分开?实现SPA和MPA混合的最佳方法。 最佳答案 我已经使用过的一些选项:使用Laravel渲染“主视图”+连接vue.js应用。基本上,laravel将呈现Vue应用程序,并且每个请求都通过API。易于设置身份验证+用户验证更容易(您可以为此使用laravelses

javascript - 尝试使用 gh-pages 部署我的 React 应用程序但收到此错误消息 : The "file" argument must be of type string. Received type undefined

我试图用gh-pages部署我的React应用程序,但我遇到了这个错误:"file"参数必须是字符串类型。接收类型未定义。起初,我以为这是我的代码,所以我制作了另一个没有修改的create-react-app,尝试使用npmrundeploy命令进行部署,但再次收到此错误消息。我的package.json(我添加了我的homepage链接、predeploy和deploy脚本,以及gh-页面依赖):"name":"test-deploy","version":"0.1.0","private":true,"homepage":"https://vnsteven.github.io/te

javascript - 错误 TS7017 : Index signature of object type implicitly has an 'any' type in form validation angular 2

我在给出的Angular2中进行响应式(Reactive)验证时遇到编译错误errorTS7017:Indexsignatureofobjecttypeimplicitlyhasan'any'type为了this.comErrors[field]='';constmessages=this.validationMessages[field];this.comErrors[field]+=messages[key]+'';它正在按应有的方式运行,但是当我尝试运行npmrunbuild.prod时,出现错误并且无法构建我的项目这是我的代码:onValueChanged(data?:any)

javascript - 错误 TS2315 : Type 'ElementRef' is not generic material angular

在项目中添加AngularMaterial时出错ERRORinnode_modules/@angular/material/button-toggle/typings/button-toggle.d.ts(136,20):errorTS2315:Type'ElementRef'isnotgeneric.node_modules/@angular/material/button-toggle/typings/button-toggle.d.ts(154,104):errorTS2315:Type'ElementRef'isnotgeneric我正在尝试安装MaterialDesign,但