点击存缓存并跳转页面并到跳转页面取缓存

之前页面的
             html:
<image bindtap='ontTapdetails' data-item_data='{{item}}' class="videoVideo2" src="{{item.wapimg}}" }};"></image>
           
js:
  ontTapdetails: function(e) {
    console.log(e)
    //存缓存
    var item_data = e.currentTarget.dataset.item_data
    wx.setStorageSync('item_data', item_data)
    wx.navigateTo({
      url: '../details/details',
    })
  },
 
跳转之后的页面
          HTML:
 
<view class='windo'>

  <view>

    <view class='vdieo_box'>

      <view class='block' style='margin-left:20rpx;'>
        <view class="cover">
          <!-- 视频图层 -->
          <image class="videoVideo2" src="{{show_data.wapimg}}" mode="scaleToFill" id="show_data{{vid}}" style="display: {{ _index == index ?  'block' : 'none'}};"></image>
          <!-- 视频按钮 -->
          <image id="{{index}}" class="videoPlay" src="/img/bf.png" mode="scaleToFill" bindtap="videoPlay" style="display: {{ _index == index ?  'block' : 'none'}};"></image>

        </view>

      </view>
      <video src='{{show_data.videourl}}' class='vdieo' id="{{index}}"></video>
      <view class='child'>{{show_data.typename}}</view>

    </view>
    <view class='_'></view>
    <view class='__'></view>
    <view class='text'>这个作品好看吗</view>
    <view class='box1'>
      <view class='box' bindtap="onChangeShowState">
        <image  src="{{isPlaying?'/img/cai1.png':'/img/cai2.png'}}" class='had had1'  ></image>
        <text class='had_text'>不好看</text>
      </view>
      <view class='box' bindtap="onChangeShowState2">
        <image  src="{{isPlaying1?'/img/zan1.png':'/img/zan2.png'}}" class='had'></image>
        <text class='had_text'>好看</text>
      </view>
    </view>
  </view>
</view>
 
 
js:
  onLoad: function(options) {
 

    //读取缓存
   
    var show_data = wx.getStorageSync('item_data');
    console.log(show_data)
    this.setData({
show_data
    })


  },
 

猜你喜欢

转载自www.cnblogs.com/junlian/p/9810094.html