悦家开发文档 http://docs.summersky.cn/

1.安装

  1. // npm init -y npm i yuejia -S
  1. npm i yuejia
  1. npm i yuejia-cli -g //全局安装
  1. npm i //初始化
  1. npm init
  1. yj create project //新建项目
  1. npm i http-server -g
  1. npm run dev
  1. http-server

2.组件、路由

(1)组件 :

创建页面

yj create page --name Home
Home是一个可替换的变量,页面的名称要首字母大写

创建纯组件

yj create component --name Head
Head是一个可替换的变量,组件的名称要首字母大写

创建类组件

yj create component --name Head --state
Head是一个可替换的变量,组件的名称要首字母大写
—state 表示是一个类组件

在页面下创建组件

yj create component --page Home --name Card
—page 表示页面的名称,Home是一个可替换的变量
image.png

(2)路由

image.pngimage.png

3.悦家组件

image.png

(1)引入:
image.png

(2)调用:
image.png

(3)F12调试和查看该组件
image.png

4.svg图片格式的使用

(1)从ps中导出图片格式为svg格式
(2)路径导出、路径导入
const rankDown = require(‘../../assets/svg/rankDown.svg’);

/* 朝下箭头 /
rankDown: svgRootPath + rankDown.id,
image.pngimage.png
image.png
image.png
css样式:
image.png

5.背景图片的使用

image.png

6.本机配置路径

image.png

7.{status ? (): ()}, 枚举, <> </>

  1. import * as React from 'react';
  2. import * as style from './index.scss';
  3. import BasePage, { PageProps } from 'yuejia/app/Page';
  4. import Page from 'yuejia/component/Page';
  5. import View from 'yuejia/component/View';
  6. import { Context } from 'yuejia/component/Model';
  7. import config from '../../../config';
  8. import ImgView from 'yuejia/component/ImgView';
  9. import Icon from 'yuejia/component/Icon';
  10. import * as classnames from 'classnames';
  11. interface Match {
  12. }
  13. interface Props {
  14. }
  15. interface State {
  16. status: number;
  17. /** 经纪人维度排序类型 */
  18. type1: string;
  19. /** 经纪人维度排序方式 */
  20. typeS1: boolean;
  21. /** 置业顾问维度排序类型 */
  22. type2: string;
  23. /** 置业顾问维度排序方式 */
  24. typeS2: boolean;
  25. /** 判断箭头的显示与隐藏 */
  26. iconActive: boolean;
  27. /** 加载中图片 */
  28. loading: boolean;
  29. }
  30. const Complete = View.Complete;
  31. const Empty = View.Empty;
  32. const Fail = View.Fail;
  33. // const LoadingView = () => (
  34. // <div className={style.lableCon}>
  35. // <Icon src={config.svgFiles.loading} className={style.icon}></Icon>
  36. // <span>正在拼命加载中···</span>
  37. // </div>
  38. // );
  39. class ProjectRank extends BasePage<Props, State, Match> {
  40. constructor(props: PageProps<Match>, state: State) {
  41. super(props, state);
  42. this.init();
  43. this.handleChecked = this.handleChecked.bind(this);
  44. this.isIconActive = this.isIconActive.bind(this);
  45. }
  46. public state: State = {
  47. status: 0,
  48. type1: '报备量',
  49. typeS1: true,
  50. type2: '分配量',
  51. typeS2: true,
  52. iconActive: true,
  53. loading: true
  54. };
  55. /** 经纪人维度和置业顾问维度的切换 */
  56. public handleChecked = (index: number) => {
  57. const status = (index === 0) ? 0 : 1;
  58. // const { loading } = this.state;
  59. this.setState({
  60. status
  61. });
  62. }
  63. /** 箭头上下的切换 */
  64. public isIconActive = (type: string) => {
  65. const { status, type1, typeS1, type2, typeS2 } = this.state;
  66. if (status) {
  67. this.setState({
  68. type2: type,
  69. typeS2: type2 === type ? !typeS2 : true,
  70. });
  71. } else {
  72. this.setState({
  73. type1: type,
  74. typeS1: type1 === type ? !typeS1 : true,
  75. });
  76. }
  77. }
  1. public displayName: string = '项目排行';
  2. public pageName: string = '项目排行';