小编A R*_*A R的帖子

nextjs:多个子项被传递到 <Link>,其中“href”为“x”,但仅支持一个子项

我没有将多个子项传递给链接,为什么会收到此错误?href错误是:“使用of传递了多个子项/post/61703ea640ff7eef1e1e7e75,但仅支持一个子项”

return (
        <>
        {head()}
        <div className="container-fluid"
        style={{
            backgroundImage: "url( "+ "/images/default.jpg"+ ")",
            backgroundAttachment: "fixed",
            padding: "100px 0px 75px 0px",
            backgroundRepeat: 'no-repeat',
            backgroundSize: 'cover',
            backgroundPosition: 'center center',
            display: 'block'
        }}>
                <h1 className="display-1 font-weight-bold text-center py-5">MERNCAMP</h1>
        </div>
        <div className="container">
        <div className="row pt-5">
          {posts.map((post) => (
            <div key={post._id} className="col-md-4">
              <Link href={`/post/view/${post._id}`}>
                <a>
                  <PostPublic key={post._id} post={post} />
                </a>
              </Link>
            </div>
          ))}
        </div>
      </div>
          </>    
    )
Run Code Online (Sandbox Code Playgroud)

next.js

6
推荐指数
2
解决办法
1万
查看次数

angular 9 依赖注入错误。" 该类不能通过依赖注入创建,因为它没有 Angular 装饰器

相同的代码在 angular 8 中对我有用,但现在它给了我这个错误。“无法通过依赖注入创建类 'BaseService',因为它没有 Angular 装饰器。这将导致运行时出错。

Either add the @Injectable() decorator to 'BaseService', or configure a different provider (such as a provider with 'useFactory')."
Run Code Online (Sandbox Code Playgroud)

我只是想在这里实现简单的继承。

1)BaseService.ts(父类)

import { environment } from 'src/environments/environment';
import { HttpHeaders } from '@angular/common/http';

export class BaseService {
    url
    constructor(postfixUrl) {
        this.url = environment.backendUrl + postfixUrl
    }

    setUpHeaders() {
       return {
           headers: new HttpHeaders({
               'Content-Type': 'application/json'
           })
       }
} 
}
Run Code Online (Sandbox Code Playgroud)

2)AuthService.ts(子类)

import { Injectable } from "@angular/core";
import {HttpClient} from '@angular/common/http'
import { BaseService } …
Run Code Online (Sandbox Code Playgroud)

angular

3
推荐指数
2
解决办法
5904
查看次数

如何在 TRPC 中使查询无效并获取最新数据?

我只是想在执行突变后从服务器获取最新数据。我的代码看起来像这样:

  const utils = trpc.useContext()
  const markAsUnreadMutation = trpc.useMutation(['update-mark-as-unread'], {
    onSuccess() {
      utils.invalidateQueries() //THIS IS NOT WORKING!
    },
    onError(data) {
      toast({
        type: 'error',
        message: data.message,
      })
    },
  })

  function markAsUnread(isUnread: boolean) {
    markAsUnreadMutation.mutate({
      id: parseInt(channel.id),
      markAsUnread: isUnread,
    })
  }
Run Code Online (Sandbox Code Playgroud)

reactjs react-query trpc.io

3
推荐指数
1
解决办法
7767
查看次数

标签 统计

angular ×1

next.js ×1

react-query ×1

reactjs ×1

trpc.io ×1