小程序列表跳转至详情_小程序跳转链接怎么获取

小程序列表跳转至详情_小程序跳转链接怎么获取效果展示:列表页js部分:onLoad:function(options){varthat=this;wx.request({url:’你的接口’,data:{ 接口参数},header:{‘content-type’:’ap…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

2020/9/1:这种写法能实现但是用了多次缓存,后面发现其实是可以用自定义属性来传参的,具体有空我会写出来

效果展示:

小程序列表跳转至详情_小程序跳转链接怎么获取

小程序列表跳转至详情_小程序跳转链接怎么获取

 

列表页js部分:

onLoad: function(options) {

    var that = this;

    wx.request({

      url: ‘你的接口’,

      data: {

          接口参数

      },

      header: {

          ‘content-type’: ‘application/json’, // 默认值

      },

      success: function (res) {

          console.log(res.data);

          that.setData({

            你定义的变量名: res.data,

          })

      }

    })

  },

跳转详情页方法

 viewDetail: function(e) {

    let newsid = e.currentTarget.dataset.id || ”;

    let newsTitle = e.currentTarget.dataset.newstitle || ”;

    let newsAuthor = e.currentTarget.dataset.newsauthor || ”;

    let newsDescription = e.currentTarget.dataset.newsdescription || ”;

    let newsCreateTime = e.currentTarget.dataset.newscreatetime || ”;

    let newsContentText = e.currentTarget.dataset.newscontenttext || ”;

    let newsInfoSource = e.currentTarget.dataset.newsinfosource || ”;//你想传递的值

    //放入缓存

    wx.setStorage({

      key: ‘你定义key的名程’,

      data: {

        newsid,

        newsAuthor,

        newsTitle,

        newsDescription,

        newsCreateTime,

        newsContentText,

        newsInfoSource

      },

      success: function () {

        wx.navigateTo({

          url: ‘../news_home/Detail/Detail?newsid=’  + newsid + “&newsTitle” + newsTitle + “&newsAuthor” + newsAuthor

          + “&newsDescription” + newsDescription + “&newsCreateTime” + newsCreateTime + “&newsContentText” + newsContentText

          + “&newsInfoSource” + newsInfoSource

        })

      }

    })

  },

 

列表页wxml:

用data-绑定传递

 <view class=” bindtap=’viewDetail’ data-newsid='{
{item.newsid}}’ data-newstitle='{
{item.Title}}’ data-newsauthor='{
{item.Author}}’ data-newsdescription='{
{item.Description}}’ data-newscreatetime='{
{item.CreateTime}}’ data-newscontenttext='{
{item.ContentText}}’ data-newsinfosource='{
{item.InfoSource}}’>

                <view style=”width:100%”>标题:{
{item.Title}}</view>

                <view style=”width:100%”>作者:{
{item.Author}}</view>

                <view style=”width:100%”>发布时间:{
{item.CreateTime}}</view>

          </view>

 

详情页js:

从缓存中拿取数据

onShow: function () {

    let that = this;

    // 从缓存中获取

    wx.getStorage({

      key: ‘你定义key的名字’,

      success: function (res) {

        that.setData({

          newsTitle: res.data.newsTitle,

          newsAuthor:res.data.newsAuthor,

          newsDescription:res.data.newsDescription,

          newsCreateTime:res.data.newsCreateTime,

          newsContentText:res.data.newsContentText,

          newsInfoSource:res.data.newsInfoSource

        })

      },

    })

  },

 

详情页xwml:

      <view>{
{newsInfoSource}}</view>

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/171105.html原文链接:https://javaforall.net

(0)
上一篇 2022年8月18日 下午10:46
下一篇 2022年8月18日 下午11:16


相关推荐

  • eigen库的使用_vcg库

    eigen库的使用_vcg库Eigen矩阵定义#includeMatrixdouble,3,3>A;//Fixedrowsandcols.SameasMatrix3d.Matrixdouble,3,Dynamic>B;//Fixedrows,dynamiccols.Matrixdouble,Dynamic,Dynam

    2022年10月7日
    5
  • MySQL增加字段SQL语句

    MySQL增加字段SQL语句使用 ALTERTABLE 向 MySQL 数据库的表中添加字段 向 buildBaseInf 中添加字段 ALTERTABLEta nameADDCOLUM nameVARCHAR 100 DEFAULTNULLC 新加字段 AFTERold column 语句内容 table name 表明 column name 需要添加的字段名 VARCHAR 100 字段类型为 varchar 长度 100 DEFAULTNULL 默认值 NUL

    2026年3月19日
    2
  • php addslashes函数已经没用了_JAVA substring

    php addslashes函数已经没用了_JAVA substringPHP为了安全性,所以引入了个magic_quotes_gpc=On的功能,可以不需要做任何处理就能直接把单引号插入数据库中,那么对于Off时,则需要考虑单引号的问题了,而不是一味地信任运行环境。当magic_quotes_gpc=On时,使用了addslashes()处理后的数据在数据库中将以\’形式保存,如果此时直接输出的话,就会发现比自己期待的内容多了个\,因此stripslashe…

    2026年3月12日
    5
  • QT代理Delegates使用实例

    QT代理Delegates使用实例效果如下 在表格的单元格中插入控件 用 Delegates 方式实现 源代码如下 main cpp 文件 include include include include include include datedelegate h include combodelegat h inclu

    2026年3月19日
    2
  • 在Ubuntu下安装和配置OpenClaw

    在Ubuntu下安装和配置OpenClaw

    2026年3月13日
    3
  • CreateJS-TweenJS文档翻译

    CreateJS-TweenJS文档翻译TweenJS 模块 TweenJS 提供了一个简单但强大的渐变界面 它支持渐变的数字对象属性 amp CSS 样式属性 并允许链接补间动画和行动结合起来 创造出复杂的序列 简单 tween 下面的示例渐变 1000ms 内将目标的 alpha 属性从 0 1 渐变 之后调用 handleComple 函数 target alpha 0 createjs Tween get targ

    2025年9月18日
    7

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号