小编kja*_*amp的帖子

类型“从不”打字稿/反应上不存在属性

当我尝试在 React 中运行我的代码时,我收到“属性 'activationDate' 不存在于类型 'never'' 错误,这会是什么问题?我确定它与打字稿有关。

编辑:仍然对导师类型有任何问题吗?不知道这是什么意思?

第二次编辑:作为参考,我正在按照本教程(https://alligator.io/react/axios-react/)进行简单的 GET 请求,我只是不知道如何将其转换为打字稿。

const TOKEN_KEY:string = `mpp-tk`;

type mentor = { activationDate: any }


class SamSearch extends React.Component<any>  {

  public state = {
    mentors: mentor[] // or any[]
  }

public componentDidMount() {
    const token = localStorage.getItem(TOKEN_KEY);
  const config = {
    headers: {
      Authorization : token
    }
  }

axios.get(`http://localhost:8080/findMentorFromSam/001339159`, config)
  .then(res => {
    console.log(res.data);
    const mentors = res.data;
    this.setState({ mentors });
  })


 }



public render(): React.ReactNode {
    const {
      classes
    } …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs

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

Angular 7 - 使用 ngFor 将数组中的最后一项设为链接

我有一个菜单项列表,我想将数组中的最后一项设为链接。

现在,菜单项是从组件构建的,但我不确定如何使数组中的最后一项成为链接。

ActionMenuItem.component.html

  <div *ngIf="expanded">
  <actionmenuitem *ngFor="let child of line.children" [line]="child" (inWorkspace)="toWorkspace($event)"></actionmenuitem>
Run Code Online (Sandbox Code Playgroud)

ActionMenuItem.Component.ts

  onSelect(){
// If it has children, expand them && flip carat.
if(this.line.children.length > 0){

  this.expanded = !this.expanded;

  if(this.iconName == "expand_more"){
    this.iconName = "expand_less"
  } else {
    this.iconName = "expand_more"
  }

} else {
  this.inWorkspace.emit(this.line);
}
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular angular7 angular8

4
推荐指数
1
解决办法
2741
查看次数

如何在 Azure 上单独部署带有 Net Core API 的 Angular 7

现在我有一个以 Angular 7 作为客户端的 .Net Core 应用程序

我在 Azure 上部署了 API 和客户端,但是我一直在思考如何让客户端在到达 .Net Core 端点的 azure 上工作。在我的登录帖子请求中,我收到了 404,但它适用于我的本地构建......我不确定我做错了什么?

    Request Method: POST
Status Code: 404 Not Found
Referrer Policy: no-referrer-when-downgrade
Run Code Online (Sandbox Code Playgroud)

azure .net-core asp.net-core angular angular7

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