2018年9月

问题:navigator和tabBar同样URL地址无法使用的问题。详细查看【网页地址

当url和tabar的地址一致时候,navgator要增加open-type="switchTab"的属性。

  <navigator url="/pages/loan/index" open-type="switchTab">
            <text class="txt">地址一</text>
          </navigator>

其他情况,可加open-type="navigate",默认情况下也是这个属性

  <navigator url="/pages/loan/index" open-type="navigate">
            <text class="txt">地址二</text>
          </navigator>

wxml代码

<view class="notice">
<view class="title">公告:</view>
<swiper class="swiper_container" vertical="true" autoplay="true" circular="true" interval="2000">
    <block wx:for="{{msgList}}" wx:key="{{item}}">
      <navigator url="/pages/index/index?title={{item.url}}" open-type="navigate">
        <swiper-item>
          <view class="swiper_item">{{item.title}}</view>
        </swiper-item>
      </navigator>
    </block>
  </swiper>
  </view>

数据js

msgList: [
{ url: "url", title: "多地首套房贷利率上浮 热点城市渐迎零折扣时代" },
{ url: "url", title: "悦如公寓三周年生日趴邀你免费吃喝欢唱城市渐迎零折扣时代" },
{ url: "url", title: "你想和一群有志青年一起过生日嘛?" }],
wxss样式

.notice {
 width: 750rpx;
 position: relative;
 margin-top:12rpx;
 }
.notice .title{
 width: 151rpx; 
 float: left;
 text-align: center;
 font-size: 30rpx;
 line-height:55rpx;
}
.notice .swiper_container {
height: 55rpx;
width: 600rpx;
line-height:55rpx;
float: right;
}

wxml代码

<swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
    <swiper-item wx:for="{{imgUrls}}" wx:key="{{item.id}}">
      <navigator url="{{item.action}}">
        <image src="{{item.photo}}" background-size="cover"></image>
      </navigator>
    </swiper-item>
  </swiper>

js代码
嵌套在data:{}里面
imgUrls:[

  {"id":1,"action":"#","photo":"/static/demo/1.jpg"},
  {"id":2,"action":"#","photo":"/static/demo/2.jpg"},
  {"id":3,"action":"#","photo":"/static/demo/3.jpg"}
],

wxss

.banner {
  width: 750rpx;
  height: 320rpx;
}
.banner image {
  width: 100%;
  height: 320rpx;
}