Skip to content

找不到命名空间“think”。 #1710

@guoqirong

Description

@guoqirong

DESC

think找不到命名空间

ENV

OS Platform:win10

Node.js Version:14.0.0

ThinkJS Version:3.2.11

code

import { Context, think } from 'thinkjs';

export default class extends think.Controller {
  constructor(ctx: Context) {
    super(ctx); // 调用父级的 constructor 方法,并把 ctx 传递进去
  }
  __before() {
    // 头部数据处理
    const method = this.method.toLowerCase();
    this.header('Access-Control-Allow-Origin', this.header('origin') || '*');
    this.header(
      'Access-Control-Allow-Headers',
      'Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, Authorization'
    );
    this.header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS,PUT,DELETE');
    this.header('Access-Control-Allow-Credentials', true);
    if (method === 'options') {
      return this.success();
    }
  }
}

error message

![Snipaste_2022-10-18_10-32-44](https://user-images.githubusercontent.com/57247313/196364803-f7cfacbf-6d8f-45f9-9787-0e15ac38e546.png)

more description

// your detail description

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions