根据代码中的报错信息,可以推断出http未被正确导入。解决办法如下:

  1. 确保在组件的顶部导入HttpClient模块:
import { HttpClient } from '@angular/common/http';
  1. 在组件的构造函数中注入HttpClient
constructor(private http: HttpClient) { }
  1. 确保在组件中的@NgModule装饰器中导入HttpClientModule
import { HttpClientModule } from '@angular/common/http';

@NgModule({
  imports: [
    HttpClientModule
  ],
  // ...
})
export class YourComponent { }

通过以上步骤,应该可以解决http未定义的问题。

let url = httpssilkroadcsdnnetapiv2assemblelistchannelsearch_hot_wordchannel_name=pc_hot_word&size=10&platform=pc; consolelog组件调用请求方法; thishttpgeturlsubscribedata = consolelog组件拿到请求返回数据;

原文地址: https://www.cveoy.top/t/topic/i0vI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录