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

小程序列表跳转至详情_小程序跳转链接怎么获取效果展示:列表页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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • windows下Elasticsearch安装、ElasticSearch-head插件安装使用[通俗易懂]

    windows下Elasticsearch安装、ElasticSearch-head插件安装使用[通俗易懂]Elasticsearch的介绍Elasticsearch是一个基于Lucene库的搜索引擎。它提供了一个分布式、支持多租户的全文搜索引擎,具有HTTPWeb接口和无模式JSON文档。Elasticsearch具有以下特点:分布式,无需人工搭建集群(solr就需要人为配置,使用Zookeeper作为注册中心)Restful风格,一切API都遵循Rest原则,容易上手近实时搜索,数据更新在Elasticsearch中几乎是完全同步的。开源的全文检索技术(Solr、Elasticsearch等)

    2022年5月18日
    93
  • 数字金额大小写转换

    数字金额大小写转换

    2021年12月17日
    34
  • 如何成为大数据架构师_业务架构师和数据架构师

    如何成为大数据架构师_业务架构师和数据架构师要想成为架构师这几点你必须关注!架构不是一个职业而是一种能力,每一种架构师只不过是在不同的领域里面使用不同的技术,没有什么可对比,就好比如你问一个篮球明星和一个足球明星有什么区别一样!01架构师需要考虑四个问题1.确定系统干什么不干什么,也就是说系统的边界在哪里?2.确定架构内部的模块与模块之间的关系,以及模块与外部之间的关系是什么?3.架构确定以后,有能力去指导…

    2025年5月28日
    0
  • cv图像翻转,EmguCV图像旋转「建议收藏」

    iusethiscodeprivatevoidbutton12_Click(objectsender,EventArgse){Bitmapbm=newBitmap(pictureBox1.Image);Imageimg=newImage(bm);doublex=20;img.Rotate(x,newGray(255));pictureBox9.Image…

    2022年4月10日
    63
  • Eclipse 汉化教程完美版

    Eclipse 汉化教程完美版1.首先查看自己的Eclipse版本号点来Help中的AboutEclipse,我的是最新版本的Oxygen。2、去官网上找对应的汉化安装包路径浏览器打开网址 http://www.eclipse.org/babel/downloads.php 找到对应自己版本的安装包我的是http://archive.eclipse.org/technology/babel/update-site/R0.15…

    2022年6月5日
    28
  • 服务器系统详细安装步骤图_服务器系统安装教程详细步骤

    服务器系统详细安装步骤图_服务器系统安装教程详细步骤一、首先按住ctrl+alt+delete进行对KVM的重启操作,在进行重启的过程中按F2,进入BIOS界面,对RAID进行磁盘阵列:1、选择DeviceSetting,进入界面后选择RAIDControllerinSlot4:进行操作。2、先选择VirtualDiskManagement命令,查看系统是否已经进行了磁盘阵列。(如果已经存在进行步骤3,如果未存在进行步骤4)3、按Esc返回上一级,选择ConfigurationManagem…

    2022年9月28日
    0

发表回复

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

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