设为首页 加入收藏

TOP

用weexplus从0到1写一个app(2)-页面跳转和文章列表及文章详情的编写(三)
2019-09-17 18:15:42 】 浏览:52
Tags:weexplus 一个 app 页面 文章 详情 编写
ic-item showLength="4" type="2"></topic-item> <homeSinger-item></homeSinger-item> <back-item v-if="show"></back-item> </scroller> </div> </template> <script> import myHeader from "../../component/header.vue";//头部组件 import titleItem from "../../component/title-item.vue";//标题组件 import newsItem from "../../component/news-item.vue"; import backItem from "../../component/back-item.vue"; import richText from "../../component/rich-text.vue";//富文本 import topicItem from "../../component/vtopic-item.vue"; import homeSingerItem from "../../component/home/singer.vue";//歌手列表组件 const navigator = weex.requireModule("navigator"); const modal = weex.requireModule("modal"); import apis from "./../util/api"; import { htmlTOJson } from "./../util/util";//解析富文本 import request from "./../util/request";//数据请求封装 export default { components: { titleItem, newsItem, backItem, richText, myHeader, topicItem, homeSingerItem }, data() { return { item: { body: [{ type: "icon", src: "" }, { type: "text", value: "", theme: "yellow" } ], title: "", pubdate: "", pic: "", author: "", normalBody: "" }, show: false, aboutItems: [], query: {} }; }, created(options) { const globalEvent = weex.requireModule("globalEvent"); globalEvent.addEventListener("onPageInit", () => { const query = navigator.param();//拿到传递的参数 this.query = query; this.refresh(); }); }, methods: { refresh(){ this.loadData(this.query.id); }, loadData(id) { //请求初始数据 const that = this; let arr = []; let data = request.get(apis.articleDetails, { id: id }).then(data => { //数据组装 }); }, gotonews(id) { // console.log(id); navigator.pushParam("./detail.js", { id: id }); // this.loadData(id); }, share() {} } }; </script> <style src="../../css/style.css"></style> <style scoped></style>

在这里需要注意几个点:

  • weex目前对富文本支持不太友好,官方是有个richtext组件,但是需要前端自己重新解析富文本内容为指定的格式,具体参见richtext文档,对这一块目前我这边也没有完美的解决方案,这里只有几个思路:1.按照官方的按照richtext组件需要的数据结构前端自己解析;2.写一个H5页面显示富文本,任何用webview嵌入;3.接口返回数据按照richtext组件需要的数据结构处理好数据。

一点私货

基于同一套ui开发出来的吉他自学小助手小程序版已经上线喜欢弹吉他的小伙伴可以关注一波 https://minapp.com/miniapp/8327/

吉他自学小助手微信小程序二维码

更多

更多前端技术分享请关注我的博客:https://hurely.github.io

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Typescript基础(4)——接口 下一篇jquery中attr和prop的区别

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目