这是:主页代码

<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="width: 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="width: 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%; width: 96;flex-wrap: wrap;}
.title{line-height: 2em;font-weight: 700;font-size: 38upx;}
.art-content{line-height: 2e}
.uni-media-list-logo{width: 400px;height: 400px;}
</style>

图片演示:

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

使用Vue前端框架实现知乎日报app的更多相关文章

  1. vue 前端框架 目录

    vue 前端框架 目录   vue-目录 ES6基础语法 vue基础语法 Vue.js的组件化思想 —上 Vue.js的组件化思想 —下 Vue + Vue-Router结合开发 SublimeSer ...

  2. 4.VUE前端框架学习记录四:Vue组件化编码2

    VUE前端框架学习记录四:Vue组件化编码2文字信息没办法描述清楚,主要看编码Demo里面,有附带完整的代码下载地址,有需要的同学到脑图里面自取.脑图地址http://naotu.baidu.com/ ...

  3. 3.VUE前端框架学习记录三:Vue组件化编码1

    VUE前端框架学习记录三:Vue组件化编码1文字信息没办法描述清楚,主要看编码Demo里面,有附带完整的代码下载地址,有需要的同学到脑图里面自取.脑图地址http://naotu.baidu.com/ ...

  4. 2.VUE前端框架学习记录二

    VUE前端框架学习记录二:Vue核心基础2(完结)文字信息没办法描述清楚,主要看编码实战里面,有附带有一个完整可用的Html页面,有需要的同学到脑图里面自取.脑图地址http://naotu.baid ...

  5. 1.VUE前端框架学习记录一

    VUE前端框架学习记录一文字信息没办法描述清楚,主要看编码实战里面,有附带有一个完整可用的Html页面,有需要的同学到脑图里面自取.脑图地址http://naotu.baidu.com/file/f0 ...

  6. vue 前端框架

    什么是vue.js 1.vue是目前最火的一个前端框架,react 是最流行的前端框架(react除了开发网站,还可以开发手机APP,vue语法也是可以进行手机app开发的,需要借助于weex) 2. ...

  7. 开发基于vue前端框架下的系统的UI自动化,记录总结踩的坑

    在使用了pytest完成了一个系统的UI自动化后,因为系统的前端框架,是 基于VUE写的,这就让我编写脚本的时候踩了些坑. 无法用JS 修改标签属性,从而进行的操作 比如上传图片,我们的上传是这样子的 ...

  8. 自动化测试平台(Vue前端框架安装配置)

    Vue简介: 通俗的来说Vue是前端框架,用来写html的框架,可轻量级也可不轻量级 Vue特性: 绑定性,响应性,实时性,组件性 安装软件以及控件: 控件库:element-ui node.js ( ...

  9. Vue前端框架基础+Element的使用

    前置内容: AJAX基础+Axios快速入门+JSON使用 目录 1.VUE 1.1 概述 1.2 快速入门 1.3 Vue指令 1.3.1 v-bind & v-model 指令 1.3.2 ...

随机推荐

  1. Python字符串和正则表达式中的反斜杠('\')问题

    在Python普通字符串中 在Python中,我们用'\'来转义某些普通字符,使其成为特殊字符,比如 In [1]: print('abc\ndef') # '\n'具有换行的作用 abc defg ...

  2. synchronized锁住的是代码还是对象,以及synchronized底层实现原理

    synchronized (this)原理:涉及两条指令:monitorenter,monitorexit:再说同步方法,从同步方法反编译的结果来看,方法的同步并没有通过指令monitorenter和 ...

  3. express-handlebars

    https://www.npmjs.com/package/express-handlebars

  4. Linux常用命令及Shell的简单介绍

    一.linux命令   1.查看指令的参数搭配: man 指令名称   2.基础指令 ls  列出当前目录下的所有文档的名称(文档指的是文件和文件夹) 常用参数搭配: ls -l 列出文档详细信息 l ...

  5. 2019-11-29-dotnet-使用-System.CommandLine-写命令行程序

    title author date CreateTime categories dotnet 使用 System.CommandLine 写命令行程序 lindexi 2019-11-29 08:33 ...

  6. SpringBoot打包成jar运行脚本

    #!/bin/bash #这里可替换为你自己的执行程序,其他代码无需更改 APP_NAME=csadmin.jar #使用说明,用来提示输入参数 usage(){ echo "Usage: ...

  7. C++ ->error LNK1123

    终极解决方案:VS2010在经历一些更新后,建立Win32 Console Project时会出“error LNK1123” 错误,解决方案为将 项目|项目属性|配置属性|清单工具|输入和输出|嵌入 ...

  8. (转) weblogic 域,管理服务器,受管服务器,集群和机器的基本知识

    weblogic 域,管理服务器,受管服务器,集群和机器的基本知识 1.域(Domain) •它是什么? –是一个逻辑上管理的WebLogic Server组,这些组从管理上当作一个整体来操作 •域里 ...

  9. 绕过CDN找到真实IP

    现在很多大型企业都会使用CDN内容分发网络,因为CDN存在多个缓存服务点,而且会根据用户IP地址,将用户请求导向到最近的服务点上进行相应,所以得不到主服务站点的ip地址,总结学习一下绕过CDN找到真实 ...

  10. Redis 实战之主从复制、高可用、分布式

      目录 简介 持久化 主从复制 高可用 Redis-Sentinel .NET Core开发 分布式 Redis-Cluster 配置说明 常见问题 简介 本节内容基于 CentOS 7.4.170 ...