草庐IT

vuejs-ssr-typescript

全部标签

javascript - TS2307 : Cannot find module 'angular2/core' while importing Angular2 on TypeScript

大家好,我只有一点Angular1的背景,我正在学习Angular2。从Angular1开始,唯一的依赖是添加Angular源angular.js或angular.min.js,当通过脚本标签尝试使用Angular2时,我收到类似这样的错误未捕获的ReferenceError:系统未定义未捕获的ReferenceError:define未定义所以我搜索了SE,发现system.js和require.js必须在加载angular2之前加载。我设法加载这两个库的任何方式,我喜欢编译TypeScript并提供js文件,而不是将所有脚本发送到客户端并在客户端编译/转译所有内容。我的IDE是We

javascript - 遍历 Typescript 中的对象数组

我需要以Angular2遍历对象数组并限制对象中特定键的字符串长度显示。this.productService.loadAllProducts(product).subscribe(data=>{if(this.authService.checkActiveSession(data)){if(data.success){//console.log(this.product_desc.substring(0,2))for(leti=0;i我需要在显示时将prod_desc长度限制为(比如说)10个字符:例如:this.product_desc.substring(0,10)

javascript - 遍历 Typescript 中的对象数组

我需要以Angular2遍历对象数组并限制对象中特定键的字符串长度显示。this.productService.loadAllProducts(product).subscribe(data=>{if(this.authService.checkActiveSession(data)){if(data.success){//console.log(this.product_desc.substring(0,2))for(leti=0;i我需要在显示时将prod_desc长度限制为(比如说)10个字符:例如:this.product_desc.substring(0,10)

javascript - TypeScript 中的匿名/内联接口(interface)实现

我刚刚开始使用TypeScript,我正在尝试理解为什么以下内联对象定义被视为无效。我有一个对象集合-它们的类型(对我而言)无关紧要,但它们实现了接口(interface),因此当我遍历它们时,我知道接口(interface)方法将出现在集合中的每个对象中。当我尝试使用实现所需方法所需的私有(private)信息创建对象时遇到“编译器”错误:interfaceDoable{do();}functiondoThatThing(doableThing:Doable){doableThing.do();}doThatThing({privatemessage:'ahoy-hoy!',//co

javascript - TypeScript 中的匿名/内联接口(interface)实现

我刚刚开始使用TypeScript,我正在尝试理解为什么以下内联对象定义被视为无效。我有一个对象集合-它们的类型(对我而言)无关紧要,但它们实现了接口(interface),因此当我遍历它们时,我知道接口(interface)方法将出现在集合中的每个对象中。当我尝试使用实现所需方法所需的私有(private)信息创建对象时遇到“编译器”错误:interfaceDoable{do();}functiondoThatThing(doableThing:Doable){doableThing.do();}doThatThing({privatemessage:'ahoy-hoy!',//co

javascript - TypeScript:编译删除未引用的导入

在我们的项目中,我们使用RequireJS作为我们的模块加载器。我们的一些模块会影响全局库,因此不会直接在引用它们的模块中使用。例子:define(['definitely/goingto/usethis/','just/referencingthis/forpackaging'],function(useThis){useThis.likeIPromised();//thefollowingcallcanonlybemadewhenthesecondrequiredfileisavailablesomeGlobalAvailableVariable.someMethod();});这

javascript - TypeScript:编译删除未引用的导入

在我们的项目中,我们使用RequireJS作为我们的模块加载器。我们的一些模块会影响全局库,因此不会直接在引用它们的模块中使用。例子:define(['definitely/goingto/usethis/','just/referencingthis/forpackaging'],function(useThis){useThis.likeIPromised();//thefollowingcallcanonlybemadewhenthesecondrequiredfileisavailablesomeGlobalAvailableVariable.someMethod();});这

javascript - typescript 错误运行时错误: Cannot read property 'prototype' of undefined when extending

所以我在控制台中收到上述错误。这是由于_super在传递给__extends(在生成的.js中)时未定义。下面是一些可用于重现错误的测试代码://ThisistheentiretyofthefileTest.tsmoduleTest{exportclassTest1{publicName:string;publicNumber:number;constructor(){}}}然后在一个单独的文件中,我有一个继承自该文件的类:///moduleTest{exportclassTest2extendsTest1{constructor(){super();}}}不应该需要(实际上也不需要)

javascript - typescript 错误运行时错误: Cannot read property 'prototype' of undefined when extending

所以我在控制台中收到上述错误。这是由于_super在传递给__extends(在生成的.js中)时未定义。下面是一些可用于重现错误的测试代码://ThisistheentiretyofthefileTest.tsmoduleTest{exportclassTest1{publicName:string;publicNumber:number;constructor(){}}}然后在一个单独的文件中,我有一个继承自该文件的类:///moduleTest{exportclassTest2extendsTest1{constructor(){super();}}}不应该需要(实际上也不需要)

javascript - 使用 TypeScript 和 Object.assign 给我一个错误 "property ' assign' does not exist on type 'ObjectConstructor' "

我正在重新写我的问题,因为之前它没有什么意义,而且我不是很清楚。我从API接收的数据看起来像这样:{"photos":[{"id":1,"title":"photo_1_title"}]}因此,在我的代码中,我有一个photos变量和一个名为getPhotos()的方法我正在使用无限滚动,所以当我到达页面底部时,我再次调用getPhotos()。photos:any;getPhotos(){this.photoService.getPhotos().subscribe(photos=>this.photos=photos//here,insteadofdoingthis,Iwantto