当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript types.identifier方法代码示例

本文整理汇总了TypeScript中mobx-state-tree.types.identifier方法的典型用法代码示例。如果您正苦于以下问题:TypeScript types.identifier方法的具体用法?TypeScript types.identifier怎么用?TypeScript types.identifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mobx-state-tree.types的用法示例。


在下文中一共展示了types.identifier方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

ďťżimport { types } from 'mobx-state-tree';

export const ResultItem = types.model('ResultItem', {
  id: types.identifier(types.number),
  folderId: types.optional(types.number, 0),
  title: types.string,
  url: types.string,
  icon: types.string,
  folderTitle: types.optional(types.string, ''),
});
开发者ID:GPegel,项目名称:grafana,代码行数:10,代码来源:ResultItem.ts

示例2:

import { types } from 'mobx-state-tree';

export const NavItem = types.model('NavItem', {
  id: types.identifier(types.string),
  text: types.string,
  url: types.optional(types.string, ''),
  subTitle: types.optional(types.string, ''),
  icon: types.optional(types.string, ''),
  img: types.optional(types.string, ''),
  active: types.optional(types.boolean, false),
  hideFromTabs: types.optional(types.boolean, false),
  breadcrumbs: types.optional(types.array(types.late(() => Breadcrumb)), []),
  children: types.optional(types.array(types.late(() => NavItem)), []),
});

export const Breadcrumb = types.model('Breadcrumb', {
  title: types.string,
  url: types.string,
});
开发者ID:cboggs,项目名称:grafana,代码行数:19,代码来源:NavItem.ts

示例3:

import { types, getEnv, flow } from 'mobx-state-tree';

export const TeamMember = types.model('TeamMember', {
  userId: types.identifier(types.number),
  teamId: types.number,
  avatarUrl: types.string,
  email: types.string,
  login: types.string,
});

type TeamMemberType = typeof TeamMember.Type;
export interface ITeamMember extends TeamMemberType {}

export const TeamGroup = types.model('TeamGroup', {
  groupId: types.identifier(types.string),
  teamId: types.number,
});

type TeamGroupType = typeof TeamGroup.Type;
export interface ITeamGroup extends TeamGroupType {}

export const Team = types
  .model('Team', {
    id: types.identifier(types.number),
    name: types.string,
    avatarUrl: types.string,
    email: types.string,
    memberCount: types.number,
    search: types.optional(types.string, ''),
    members: types.optional(types.map(TeamMember), {}),
    groups: types.optional(types.map(TeamGroup), {}),
开发者ID:cboggs,项目名称:grafana,代码行数:31,代码来源:TeamsStore.ts

示例4: toggle

ďťżimport { types } from 'mobx-state-tree';
import { ResultItem } from './ResultItem';

export const SearchResultSection = types
  .model('SearchResultSection', {
    id: types.identifier(),
    title: types.string,
    icon: types.string,
    expanded: types.boolean,
    items: types.array(ResultItem),
  })
  .actions(self => ({
    toggle() {
      self.expanded = !self.expanded;

      for (let i = 0; i < 100; i++) {
        self.items.push(
          ResultItem.create({
            id: i,
            title: 'Dashboard ' + self.items.length,
            icon: 'gicon gicon-dashboard',
            url: 'asd',
          })
        );
      }
    },
  }));
开发者ID:GPegel,项目名称:grafana,代码行数:27,代码来源:SearchResultSection.ts


注:本文中的mobx-state-tree.types.identifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。