标签:new func set 哈哈哈哈哈哈 查看 应用 images over oca
{ "pages" : [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "path" : "pages/index/index", "style" : { "navigationBarTitleText" : "知乎日报" } }, { "path" : "pages/index/details", "style" : { "navigationBarTitleText" : "详情" } } ], "globalStyle" : { "navigationBarTextStyle" : "black", "navigationBarTitleText" : "uni-app", "navigationBarBackgroundColor" : "#F8F8F8", "backgroundColor" : "#F8F8F8" } }
<template>
<view class="content">
<view class="uni-list">
<!-- <navigator url="">页面跳转</navigator> -->
<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,index) in news" :key="index" @tap="opendet" :data-newsid="item.id">
<view class="uni-media-list">
<image class="uni-media-list-logo" :src="item.images[0]"></image>
<view class="uni-media-list-body">
<view class="uni-media-list-text-top">{{item.title}}</view>
<view class="uni-media-list-text-bottom uni-ellipsis">{{item.ga_prefix }}</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
news: []
};
},
onLoad: function() {
uni.request({
url: ‘https://news-at.zhihu.com/api/4/news/latest‘,
method: ‘GET‘,
data: {},
success: res => {
//console.log(res);
this.news = res.data.stories;
}
});
},
methods: {
opendet(e){
var newid = e.currentTarget.dataset.newsid;
console.log(newid);
uni.navigateTo({
url: ‘../index/details?newsid=‘+newid
});
}
}
}
</script>
<style>
.uni-media-list-body {
height: auto;
}
.uni-media-list-text-top {
line-height: 1.6em;
}
</style>

<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,index) in news" :key="index" @tap="opendet" :data-newsid="item.id">
<template>
<view class="content">
<view class="title">{{title}}</view>
<view class="api-centent">
<rich-text class="richText" :nodes="bodys" style="width: 100%; height: 100%;"></rich-text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: ‘‘,
bodys: ‘‘,
share_url:‘‘
}
},
onLoad: function(e) {
console.log(e.newsid);
uni.request({
url: ‘https://news-at.zhihu.com/api/4/news/‘ + e.newsid,
method: ‘GET‘,
data: {},
success: res => {
/* console.log(res.data); */
/* this.title = res.data.title; */
this.bodys = res.data.body;
/* this.bodys = this.bodys.indexOf("“");
console.log(this.bodys); */
//replace()方法在字符串中用一些字符替换另一些字符
//stringObject.replace(regexp/substr,replacement)
this.bodys = this.bodys.replace(/“/g, ‘"‘);
this.bodys = this.bodys.replace(/”/g, ‘"‘);
},
fail: () => {
console.log("eeeeee");
},
complete: () => {}
});
}
}
</script>
<style>
.content {
/* flex-wrap:wrap允许下面元素自动换行 */
padding: 10upx 2%;
width: 96%;
flex-wrap: wrap;
}
.title {
line-height: 2em;
font-weight: 700;
font-size: 38upx;
}
.api-centent {
line-height: 2em;
}
</style>

啊哈哈哈哈哈哈哈哈哈,做的不好的地方,各位大神莫笑,还请多多指教,经验不足!
标签:new func set 哈哈哈哈哈哈 查看 应用 images over oca
原文地址:https://www.cnblogs.com/gk126/p/10015350.html