最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序視圖template模板引用的實(shí)例詳解

 更新時(shí)間:2017年09月20日 11:42:12   作者:今天一點(diǎn)也不冷  
這篇文章主要介紹了微信小程序視圖template模板引用的實(shí)例詳解的相關(guān)資料,希望通過(guò)本文能幫助到大家,需要的朋友可以參考下

微信小程序視圖template模板引用的實(shí)例詳解

WXML 提供兩種文件引用方式import和include。

include可以將目標(biāo)文件除了的整個(gè)代碼引入,相當(dāng)于是拷貝到include位置

temlate.wxml

<template name="tmp_data" >

   <view class="content">
    <!-- 頭像 -->
    <view class="author-date"> 
      <image src="{{item.header_url}}" class="author"></image>
      <text class="date">{{item.date}}{{idx}}</text>
    </view>
    <!-- 標(biāo)題內(nèi)容 -->
     <text class="title">{{item.title}}</text>
     <image class="image" src="{{item.image_url}}"></image>
     <text class="article-content">{{item.content}}</text>
    <view >

     <image class="article-images" src="../../images/icon/chat.png"></image>
     <text class="article-text">66</text>

     <image class="article-images" src="../../images/icon/view.png"></image>
     <text class="article-text">88</text>

    </view>


  </view>

</template>

redirect.wxml引用

<import src="template/template.wxml" />

template.js

var content_for = [
 {
  date: "2020年 10月 9日 ",
  title: "那年夏天",
  header_url: "/images/3.png",
  image_url: "/images/6.jpg",
  content: "天不言自高,地不言自厚,奇跡,是不會(huì)在容易的道路上綻放的。人生沒(méi)有如果,只有后果和結(jié)果,過(guò)去的不再回來(lái),回來(lái)的不再完美。",
 },
 {
  date: "2022年 10月 9日 ",
  title: "夏天",
  header_url: "/images/3.png",
  image_url: "/images/8.jpg",
  content: "人生沒(méi)有如果,只有后果和結(jié)果,過(guò)去的不再回來(lái),回來(lái)的不再完美。",
 },

]
//輸出出口
module.exports={
 templates: content_for
}

redirect.js引用

var content_data=require('../../template/template.js')
// pages/redirect/redirect.js
Page({

 /**
  * 頁(yè)面的初始數(shù)據(jù)
  */
 data: {

 },

 /**
  * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
  */
 onLoad: function (options) {

   this.setData({
     key: content_data.templates
   });

 }

});

wxml

 <block wx:for="{{key}}" wx:for-item="item" wx:for-index="idx">
     <!-- is就是模板名字name值 -->
     <template is="tmp_data" data="{{item}}" />
   </block>

template.wxss文件

.title{
 font-size: 34rpx;
 font-weight: 600;
 color:#333;
 margin-bottom: 20px;
}

redirect.wxss文件引用上面樣式

@import "template/template.wxss" //使用import定義

swiper{
 width:100%;
 height:500rpx;
}
swiper image{
  width:100%;
 height:500rpx;
}

本站關(guān)于小程序的文章還有很多,希望大家能搜索查閱,希望通過(guò)本文能幫助到大家,謝謝大家對(duì)本站的支持,

相關(guān)文章

最新評(píng)論

南岸区| 四子王旗| 聊城市| 徐州市| 洛川县| 阿合奇县| 邯郸市| 综艺| 浑源县| 桦南县| 靖宇县| 永年县| 昌都县| 徐闻县| 资溪县| 阜城县| 皮山县| 钦州市| 金山区| 哈巴河县| 普格县| 芜湖市| 马公市| 瓮安县| 凌云县| 枞阳县| 吉林省| 洛南县| 兰溪市| 多伦县| 大名县| 文登市| 新乡县| 拉孜县| 罗山县| 察雅县| 深泽县| 绍兴县| 乐昌市| 西安市| 乌苏市|