我从正在学习的在线MOOC中下载了该项目的zip文件。到现在为止一切正常,但是现在我遇到了如下所述的错误:
我尝试ng serve再次运行,并且也npm install再次运行,但是每次遇到以下错误时:
node_modules / rxjs-compat / operator / shareReplay.d.ts(2,10)中的错误:错误TS2305:模块'“ / Users / ratnabhkumarrai / Downloads / prj-http-final 3 / node_modules / rxjs / internal-compatibility / index “”没有导出的成员'ShareReplayConfig'。
import { Observable, SchedulerLike } from 'rxjs';
import { ShareReplayConfig } from 'rxjs/internal-compatibility';
/**
* @method shareReplay
* @owner Observable
*/
export declare function shareReplay<T>(this: Observable<T>, config:
ShareReplayConfig): Observable<T>;
export declare function shareReplay<T>(this: Observable<T>,
bufferSize?: number, windowTime?: number, scheduler?: SchedulerLike):
Observable<T>;
Run Code Online (Sandbox Code Playgroud) 我尝试通过服务通过主题将数据从一个组件传递到另一个组件,但收到以下错误
类型“Subject(any)”上不存在属性“emit”。
这就是我尝试过的
组件.ts 文件
import { Component, OnInit } from '@angular/core';
import { Productservice } from 'src/app/services/products.service';
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-admin-products',
templateUrl: './admin-products.component.html',
styleUrls: ['./admin-products.component.scss']
})
export class AdminProductsComponent implements OnInit {
listofproducts
editedproduct
constructor(private prservice:Productservice,private
router:Router,private route:ActivatedRoute) {
}
ngOnInit() {
this.listofproducts=this.prservice.getallproducts()
}
onclickedit(id){
this.editedproduct=this.prservice.getspecificproduct(id)
this.prservice.editproduct.emit(this.editedproduct)
this.router.navigate(['edit',id],{relativeTo:this.route})
}
}
Run Code Online (Sandbox Code Playgroud)
所以在这里发出它说属性'emit'在类型'Subject(any)上不存在
服务文件
import { Subject } from "rxjs";
import { Items } from "../home/header/admin-products/items.modal";
export class Productservice{
productcard=new Subject<any>()
editproduct=new Subject<any>()
getallproducts(){ …Run Code Online (Sandbox Code Playgroud) 我刚开始使用递归,所以我正在解决一个问题,就像
创建一个函数,将数字作为参数,将它们相加,然后返回数字的乘积,直到答案只有 1 位长。
sumDigProd(16, 28) ? 6
// 16 + 28 = 44
// 4 * 4 = 16
// 1 * 6 = 6
sumDigProd(0) ? 0
sumDigProd(1, 2, 3, 4, 5, 6) ? 2
Run Code Online (Sandbox Code Playgroud)
所以我用递归来做
function sumDigProd(...digits) {
let ans = digits.reduce((a, b) => a + b, 0);
console.log(ans);
const result=calc(ans);
function calc(ans) {
ans = ans.toString();
let pro = 1;
for (let i = 0; i < ans.length; i++) {
pro = pro * ans[i];
} …Run Code Online (Sandbox Code Playgroud) 我正在将 nextjs 与 tailwindcss 结合使用,并且在将 postcss-nesting 添加到我的 nextjs 应用程序中时遇到困难。
以下是相同的配置:
next.config.js
const withPlugins = require("next-compose-plugins");
module.exports = withPlugins([], {});
Run Code Online (Sandbox Code Playgroud)
postcss.config.js
module.exports = {
plugins: [
"postcss-import",
"tailwindcss",
"autoprefixer",
"tailwindcss/nesting",
"postcss-nested",
],
};
Run Code Online (Sandbox Code Playgroud)
tailwind.config.js
module.exports = {
purge: {
enabled: true,
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./src/components/**/*.{js,ts,jsx,tsx}",
],
},
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
};
Run Code Online (Sandbox Code Playgroud)
在我的自定义 css 文件中,我尝试像这样使用它
.toolbar_navigation_items {
li {
@apply text-3xl;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我收到错误
"(2:3) Nested CSS was detected, but CSS nesting has …Run Code Online (Sandbox Code Playgroud)