在类外声明变量

时间:2019-01-08 16:16:34

标签: typescript

我当时正在考虑在Angular中设置Apollo,我看到它们在类之外创建了一些变量。 他们为什么这样做呢?这样做比创建只读变量有什么好处吗?

我看到的是:https://www.apollographql.com/docs/angular/basics/queries.html#basics

// imports....

const CurrentUserForProfile = gql`
   query CurrentUserForProfile {
       currentUser {
          login
          avatar_url
       }
    }
`;

@Component({ ... })
class ProfileComponent implements OnInit, OnDestroy {
    loading: boolean;

0 个答案:

没有答案