Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
guoqirong opened this issue Oct 18, 2022 · 0 comments
Open

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

guoqirong opened this issue Oct 18, 2022 · 0 comments

Comments

@guoqirong
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant