Troila Mobile Ui

Troila Mobile Ui

  • Docs
  • API
  • Help
  • Blog

›卓朗云桌面-内部组件

Troila Mobile Ui

  • Getting Started

Components

  • Text
  • ListView
  • List
  • TextInput
  • InputItem
  • Step
  • SpringAnimatedView

卓朗云桌面-内部组件

  • request (请求类)
  • BackgroundButton
  • ExtendsBackButton
  • HeaderTitleButton
  • HeaderImageButton
  • 注意事项
  • 不同平台和设备的入口

request

请求类 基于react-native的fetch的封装

log参数 基于troila-mobie-tools@1.1.2版本,如果低于此版本请升级 基于troila-mobie-tools@1.1.0版本,如果低于此版本请升级

规则

  • 全部基于Promise
  • 需要和外部类配合使用
  • 必须要先调用initLibraryConfigFunc完成初始化
  • 请求结果以Promise结果返回

先在APP_ROOT_NETWORK_CONFIG中配置接口信息

// utils/APP_ROOT_NETWORK_CONFIG.js
const ROOT_URL = `${domain}/tdv2/`;
export const API_URL = {
  // ...other api
    MOBILEDOLOGIN: {
        domain: ROOT_URL,
        apiUrl: 'mobile/doLogin',
        author: '会飞的鱼',
        fetchUrl: `${ROOT_URL}mobile/doLogin`,
        remark: '用户名和密码验证',
        method: 'POST',
        showLoading: true,
        needLogin: false,
        developer: boy1,
        mock: false,
        mockFetchUrl: `${MOCK_ROOT_URL}Adv/lists`,
        log: true
    },
}

API_URL key

属性说明示例
apiName接口名全大写,去除/的拼合单例字符MOBILEDOLOGIN
domain接口域名ROOT_URL
apiUrl接口地址mobile/doLogin
author接口作者会飞的鱼
fetchUrl请求时调用的真实地址${ROOT_URL}mobile/doLogin
remark接口备注用户名和密码验证
method请求方式GET,POST
showLoading是否在请求的时候显示loadingtrue
needLogin在请求前是否验证需要登陆false
developer联调接口的开发者boy1
mock是否开启mock模式false
mockFetchUrlmock模式请求的地址${MOCK_ROOT_URL}Adv/lists
log是否开启请求日志输出false

再使用request发起请求

import React, { Component } from 'react';
import {
    Button,
} from 'react-native';
import { request } from "../../utils";

class Example extends Component {
    render() {
        return (
            <Button
                title={'登陆'}
                onPress={
                  async()=>{
                    const e = await request.fetch({
                        apiName: 'MOBILEDOLOGIN',
                        params: {
                            device: 'mobile'
                        },
                        headers: {
                            Tusername: 'zhangsan',
                            Tpassword: 'a123456'
                        }
                    })
                    console.log(e);
                    // {"isLogin": 1}
                }}
            />
        );
    }
}

request.fetch api

属性说明示例是否必填
apiName在API_URL中定义的接口名(key键名)MOBILEDOLOGIN必填
paramsbody参数{device: 'mobile'}非必填
headers额外的headers{Tusername: 'zhangsan',Tpassword: 'a123456'}非必填
← SpringAnimatedViewBackgroundButton →
  • 规则
  • 先在APP_ROOT_NETWORK_CONFIG中配置接口信息
  • API_URL key
  • 再使用request发起请求
  • request.fetch api
Troila Mobile Ui
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2018 Your Name or Your Company Name