内容详情

小程序内容详情的调用方式

js中进行赋值

1、导入API文件路径

const api = require('../../utils/api.js');  //路径根据自己的实际情况调整

2、在 js 生命周期函数--监听页面加载中编写赋值代码

let that = this;

// 获取内容详情id

that.id = options.id;

that.getContent();

3、在 js 中添加自定义赋值代码

getContent() {

  let that = this;

  api.getContent(that.id).then(function (content) {

    // 使用wxParse解析富文本

    wxParse.wxParse('content', 'html', content.data.content, that, 5);

  })

},

1、页面调用方式

<template is="wxParse" data="{{wxParseData:content.nodes}}" />

可使用的小程序内容详情标签

{{ content.id }}编号
{{ content.scode }}分类编码
{{ content.subscode }}副分类编码
{{ content.sortname }}分类名称
{{ content.subsortname }}副分类名称
{{ content.sortlink }}分类链接
{{ content.subsortlink }}副分类链接
{{ content.title }}标题
{{ content.titlecolor }}标题颜色
{{ content.subtitle }}副标题
{{ content.author }}作者
{{ content.source }}来源
{{ content.link }}链接
{{ content.outlink }}外部链接
{{ content.date }}发布日期
{{ content.ico }}缩略图
{{ content.pics }}多图
{{ content.content }}内容
{{ content.tags }}直接输出tags
{{ content.enclosure }}附件
{{ content.enclosuresize }}附件大小
{{ content.keywords }}关键词
{{ content.description }}描述
{{ content.istop }}是否置顶
{{ content.isrecommend }}是否推荐
{{ content.isheadline }}是否头条
{{ content.visits }}访问数量
{{ content.likes }}点赞数量
{{ content.oppose }}反对数量
{{ content.likeslink }}点赞链接
{{ content.opposelink }}反对链接
{{ content.ext_*** }}调取扩展字段内容
{{ content.pretitle }}上一篇内容标题
{{ content.nexttitle }}下一篇内容标题
{{ content.nexttitle notext='no more' }}设置“没有了”文本,设置参数时如果带空格,需要用单引号
 阅 439