Giter Site home page Giter Site logo

Comments (4)

sunriseydy avatar sunriseydy commented on July 19, 2024 2

感谢这位老哥的想法,我将文章的标题也给解析了,解决了文章标题连字符、&符号等特殊字符的显示问题。更改的代码如下(按需修改)
首页滚动文章标题和列表文章标题:

//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.

iamxjb avatar iamxjb commented on July 19, 2024 1

谢谢,我将加入进去的

from winxin-app-watch-life.net.

iamxjb avatar iamxjb commented on July 19, 2024

你的思路不错。另外也可以考虑用rich-text组件来显示标题等非文章的内容

from winxin-app-watch-life.net.

sunriseydy avatar sunriseydy commented on July 19, 2024

正在尝试用 rich text ,不知道自己能不能填了这个坑呢

from winxin-app-watch-life.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.