zoukankan      html  css  js  c++  java
  • 使用Vue前端框架实现知乎日报app

    这是:主页代码

    <template>
        <view class="content">
            <view class="uni-list">
                <!--这是图片轮播的-->
                 <swiper :indicator-dots="true"  :autoplay="true" :interval="3000" :duration="500">
                    <swiper-item v-for="item in top_stories " :key="item" @tap="openinfo" :data-newsid="item.id">
                    <image :src="item.images" style=" 100%;"></image>
                    </swiper-item>
                </swiper>
                <text>今日热闻</text>
                <!--这是列表信息-->
                <view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,index) in list" :key="index" @tap="openinfo"
                 :data-newsid="item.id">
            
                    <view class="uni-media-list">
                        <image class="uni-media-list-logo" :src="item.images"></image>
                        <view class="uni-media-list-body">
                            <view class="uni-media-list-text-top">{{item.title}}</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </template>
    
    <script>
        export default {
            data() {
                return {
                    list: [],
                    top_stories: []
                };
            },
            onLoad: function() {
    
                uni.request({
                    url: 'https://news-at.zhihu.com/api/4/news/latest',
                    method: 'GET',
                    success: res => {
                        this.list = res.data.stories;
                        this.top_stories = res.data.stories;
                        
                    },
                    fail: () => {},
                    complete: () => {}
                });
            },
            methods: {
                openinfo(e) {
                    var newsid = e.currentTarget.dataset.newsid;
                    uni.navigateTo({
                        url: '../info/info?newsid=' + newsid,
                    });
                },
            }
        }
    </script>
    
    <style>
        .uni-media-list-body {
            height: auto;
        }
    
        .uni-media-list-text-top {
            line-height: 1.6em;
        }
    </style>

    这是:跳转后页面主题的信息

    <template>
        <view class="content">
            <view><image class="uni-media-list-logo" :src="imgage" style=" 400px;height: 400px;"></image></view>
            <view class="title">{{title}}</view>
            <view class="art-content">
                <rich-text class="richText"  :nodes="strings"></rich-text>
            </view>
        </view>
    </template>
    
    <script>
        export default {
            data(){
                return{
                    title:'',
                    strings:'',
                    imgage:''
                }    
            },
            onLoad:function(e){
                uni.request({
                    url: 'http://news-at.zhihu.com/api/2/news/'+e.newsid,
                    method: 'GET',
                    data: {},
                    success: res => {
                        this.title=res.data.title;
                        // 替换中文双引号
                        this.strings=res.data.body.replace("type=“text/javascript”",'type="text/javascript"');
                        this.imgage=res.data.image;
                    },
                    fail: () => {},
                    complete: () => {}
                });
            }
        }
    
    </script>
    
    <style>
    .content{padding: 10upx 2%;  96;flex-wrap: wrap;}
    .title{line-height: 2em;font-weight: 700;font-size: 38upx;}
    .art-content{line-height: 2e}
    .uni-media-list-logo{ 400px;height: 400px;}
    </style>

    图片演示:

    资源地址:https://github.com/nongzihong/uni_app_zhihuribao

  • 相关阅读:
    Dubbo之SPI实现原理详解
    Java SPI详解
    Java是如何实现自己的SPI机制的
    Dubbo的负载均衡原理解析
    Dubbo公开课
    【todo】什么是沟子函数
    一步一图,带你走进 Netty 的世界!
    https://github.com/xiaojiaqi/k8seasy_release_page
    mysql 8.0导致5.6数据后 :ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
    Ansible 日常使用技巧
  • 原文地址:https://www.cnblogs.com/nongzihong/p/10020858.html
Copyright © 2011-2022 走看看