使用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="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的更多相关文章
- vue 前端框架 目录
vue 前端框架 目录 vue-目录 ES6基础语法 vue基础语法 Vue.js的组件化思想 —上 Vue.js的组件化思想 —下 Vue + Vue-Router结合开发 SublimeSer ...
- 4.VUE前端框架学习记录四:Vue组件化编码2
VUE前端框架学习记录四:Vue组件化编码2文字信息没办法描述清楚,主要看编码Demo里面,有附带完整的代码下载地址,有需要的同学到脑图里面自取.脑图地址http://naotu.baidu.com/ ...
- 3.VUE前端框架学习记录三:Vue组件化编码1
VUE前端框架学习记录三:Vue组件化编码1文字信息没办法描述清楚,主要看编码Demo里面,有附带完整的代码下载地址,有需要的同学到脑图里面自取.脑图地址http://naotu.baidu.com/ ...
- 2.VUE前端框架学习记录二
VUE前端框架学习记录二:Vue核心基础2(完结)文字信息没办法描述清楚,主要看编码实战里面,有附带有一个完整可用的Html页面,有需要的同学到脑图里面自取.脑图地址http://naotu.baid ...
- 1.VUE前端框架学习记录一
VUE前端框架学习记录一文字信息没办法描述清楚,主要看编码实战里面,有附带有一个完整可用的Html页面,有需要的同学到脑图里面自取.脑图地址http://naotu.baidu.com/file/f0 ...
- vue 前端框架
什么是vue.js 1.vue是目前最火的一个前端框架,react 是最流行的前端框架(react除了开发网站,还可以开发手机APP,vue语法也是可以进行手机app开发的,需要借助于weex) 2. ...
- 开发基于vue前端框架下的系统的UI自动化,记录总结踩的坑
在使用了pytest完成了一个系统的UI自动化后,因为系统的前端框架,是 基于VUE写的,这就让我编写脚本的时候踩了些坑. 无法用JS 修改标签属性,从而进行的操作 比如上传图片,我们的上传是这样子的 ...
- 自动化测试平台(Vue前端框架安装配置)
Vue简介: 通俗的来说Vue是前端框架,用来写html的框架,可轻量级也可不轻量级 Vue特性: 绑定性,响应性,实时性,组件性 安装软件以及控件: 控件库:element-ui node.js ( ...
- Vue前端框架基础+Element的使用
前置内容: AJAX基础+Axios快速入门+JSON使用 目录 1.VUE 1.1 概述 1.2 快速入门 1.3 Vue指令 1.3.1 v-bind & v-model 指令 1.3.2 ...
随机推荐
- django1.9安装以及使用
安装setuptoolswget --no-check-certificate https://pypi.python.org/packages/69/56/f0f52281b5175e3d9ca86 ...
- C#获取主机信息
获取主机信息 最近需要做一个配合集控系统收集各个终端设备的一些信息,大致需要收集终端设备的硬件信息,CPU.内存以及硬盘使用率等信息.网上查看了一番,使用WMI来获取这些信息是最方便的.实现代码如下: ...
- log4net日志输出配置即输出到文件又输出到visual studio的output窗口
<configuration> <configSections> <section name="log4net" type="log4net ...
- 一篇关于for循环的简单题练习,
package practice; public class Practice { public static void main(String[] args) { 7. * ** ...
- vue history模式 ios微信分享坑
vue history模式 ios微信分享坑 问题分析:因为苹果分享会是调取签名失败是因为:苹果在微信中浏览器机制和安卓不同,有IOS缓存问题,和IOS对单页面的优化问题,通俗点说安卓进行页面跳转分享 ...
- apache 部署
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.localhost DocumentRoot "D:/EmpireServ ...
- visual studio密钥
企业版:NJVYC-BMHX2-G77MM-4XJMR-6Q8QF 专业版:KBJFW-NXHK6-W4WJM-CRMQB-G3CDH
- CentOS7位安装MySql教程
1.先检查系统是否装有mysql rpm -qa | grep mysql 2.下载mysql的repo源 wget http://repo.mysql.com/mysql-community-rel ...
- zabbix服务的布置(脚本)
一,服务端配置 #!/bin/bash#clsn #设置解析 注意:网络条件较好时,可以不用自建yum源# echo '10.0.0.1 mirrors.aliyuncs.com mirrors.al ...
- 解决bootstrap下的图片自适应问题
.img-responsive { display: block; height: auto; max-width: 100%; }