本文整理汇总了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, ''),
});
示例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,
});
示例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), {}),
示例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',
})
);
}
},
}));