json

import React, {Component} from 'react';
import {Text, View, Image, TouchableOpacity, FlatList,} from 'react-native';
import HttpUtils from "../../utils/HttpUtils";



// 第三方组件 滑动导航
import ScrollableTabView, { ScrollableTabBar, } from 'react-native-scrollable-tab-view';
import Page from "../../utils/page";
import Head from "../../utils/Head";
import commonStyles from "../../styles/common.style";
import FontAwesome from "react-native-vector-icons/FontAwesome";
import packStyles from "../Course/pack.style";
import ArticleStyles from "./Article.style";
import Resolution from "../../utils/Resolution";

export default class App extends Component {
    static navigationOptions = {
        header: null,  //隐藏顶部导航栏
    };

    constructor(props) {
        super(props);
        this.state = {
            type: 0,    //  分类
            currentPage: 1,  //   当前页
            articleList: [],
        };
        this.state = {articleList:[    ]}
    }

    componentDidMount() {
        this.Page.showPageLoading();//加载中
        this.queryArticleList();
    }

    queryArticleList() {
        HttpUtils.post(
            global.constants.articlePath,
            "typeId=" + this.state.type +
            '&page.currentPage=' + this.state.currentPage,
            (result) => {
                if(result.success) {
                    this.setState({
                        articleList: result.entity.articleList
                    })
                }else{//错误信息

                }
                this.Page.closePageLoading();//加载完成
            }
        )
    }
    render() {
        return(
            

                

                 }
                >
                    
                        {this.articleList()}
                    
                    11111
                    22222
                    3333
                    4444
                    5555
                    6666
                
                 {
                    this.Page = ref
                }}/>
            
        )
    }
    articleList(){
        return(
            
                    
                        
                            
                                {item.title}
                                
                                    {item.createTimeStr}
                                    评论{item.commentNum}
                                
                            
                            
                                
                            
                        
                    
                }
            />



        )
    }
}

获取json的地址:

https://m.eduhiker.com/mobile/article/list?typeId=0¤tPage=1
json_第1张图片
image.png

global是全局变量
constants
articlePath属性(comment点进去)


 articlePath:mainPath+'/mobile/article/list',

mainPath

const mainPath='https://m.eduhiker.com';

接下来,把这俩段绿色拼在一起

https://m.eduhiker.com/mobile/article/list

后面再加上参数的写法

"typeId=" + this.state.type +
'&page.currentPage=' + this.state.currentPage,

// 在后台的数据文档会给
            type: 0,    //  分类
            currentPage: 1,  //   当前页

就成为一开始最上面的写法了

https://m.eduhiker.com/mobile/article/list?typeId=0¤tPage=1

你可能感兴趣的:(json)