微信小程序url传参写变量的方法

具体代码如下所示:

<navigator url="../../pages/newsDetail/newsDetail?id={{news.id}}">
  <view class="list-item">
   <view class="little-item">
    <view class="left-box">
     <image src="{{news.thumb[0]}}"></image>
    </view>
    <view class="right-box">
     <view class="title">{{news.title}}</view>
     <view class="info">
      <view class="author-info">
       <view class="author-avatar">
        <image src="{{news.pubInfo.avatarUrl}}"></image>
       </view>
       <view class="author-other">
        <view>{{news.authorName}}</view>
        <!-- <view>{{news.pubInfo.introduction}}</view> -->
       </view>
      </view>
      <view>{{news.like}}赞 {{news.createAt}}</view>
     </view>
    </view>
   </view>
  </view>
 </navigator>

  直接看第一行,直接在双引号里写静态部分,用双大括号绑定变量即可。

总结

相关推荐