Comments (4)
感谢这位老哥的想法,我将文章的标题也给解析了,解决了文章标题连字符、&符号等特殊字符的显示问题。更改的代码如下(按需修改)
首页滚动文章标题和列表文章标题:
//pages\index\index.js
//放到开头
var wxDiscode = require('../../wxParse/wxDiscode.js');
//解析滚动文章标题
postsShowSwiperList: response.data.posts,
postsShowSwiperList: self.data.postsShowSwiperList.concat(response.data.posts.map(function (item) {
//item.firstImage = Api.getContentFirstImage(item.content.rendered);
//解析标题中的特殊字符
item.post_title = wxDiscode.strDiscode(item.post_title);
//解析文章列表标题
self.setData({
floatDisplay: "block",
postsList: self.data.postsList.concat(response.data.map(function (item) {
//解析标题中的特殊字符
item.title.rendered = wxDiscode.strDiscode(item.title.rendered);
var strdate = item.date
if (item.category_name != null) {
文章详情页面标题:
//pages\detail\detail.js
//下面一行放到开头
var wxDiscode = require('../../wxParse/wxDiscode.js');
//解析标题中的特殊字符
response.data.title.rendered = wxDiscode.strDiscode(res.data.title.rendered);
self.setData({
detail: response.data,
likeCount: _likeCount,
//小程序页面标题
.then(response => {
wx.setNavigationBarTitle({
//title: res.data.title.rendered
title: wxDiscode.strDiscode(res.data.title.rendered)
});
wx.hideLoading();
})
from winxin-app-watch-life.net.
谢谢,我将加入进去的
from winxin-app-watch-life.net.
你的思路不错。另外也可以考虑用rich-text组件来显示标题等非文章的内容
from winxin-app-watch-life.net.
正在尝试用 rich text ,不知道自己能不能填了这个坑呢
from winxin-app-watch-life.net.
Related Issues (20)
- ram-util中time_tran($the_time)函数中计算时间可能是有问题的 HOT 1
- 登录失败 HOT 9
- 关于激励广告,能直接通过抓包获取到内容。 HOT 1
- 文章无图片时搜索列表页、类目页的文章列表图片均不能显示 HOT 1
- 用的百度云加速,获取不了文章json,老提示502,无解了 HOT 1
- 小程序申请上线失败,个人主体,请问是什么原因呢? HOT 1
- 这个网站地址是从哪里来的呢 HOT 1
- 文章设置分类后,小程序无法显示
- 文章设置分类后,小程序无法显示 HOT 1
- 点击“喜欢” 后,小程序崩溃 HOT 1
- 打包app,首页无内容 HOT 1
- wordpress用户绑定 HOT 1
- 小程序后台服务器设置 HOT 1
- 最新版小程序编译后报错 如图 HOT 1
- scss兼容bug HOT 1
- 请问ui.scss无法导入如何解决? HOT 3
- 与jwt-auth插件冲突,导致小程序无法获取文章信息 HOT 1
- 用了个文章隐藏的插件,文章隐藏后小程序首页不展示,但是排行榜里依然展示,估计是没有过滤到字段 HOT 1
- 子比主题文章正文不显示
- api.js文件无法热重载
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winxin-app-watch-life.net.