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

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

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

微信小程序視圖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ì)在容易的道路上綻放的。人生沒有如果,只有后果和結(jié)果,過去的不再回來,回來的不再完美。",
 },
 {
  date: "2022年 10月 9日 ",
  title: "夏天",
  header_url: "/images/3.png",
  image_url: "/images/8.jpg",
  content: "人生沒有如果,只有后果和結(jié)果,過去的不再回來,回來的不再完美。",
 },

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

redirect.js引用

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

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

 },

 /**
  * 生命周期函數(shù)--監(jiān)聽頁面加載
  */
 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)于小程序的文章還有很多,希望大家能搜索查閱,希望通過本文能幫助到大家,謝謝大家對(duì)本站的支持,

相關(guān)文章

最新評(píng)論

吴江市| 吴旗县| 始兴县| 宜城市| 稷山县| 新源县| 贞丰县| 德阳市| 无锡市| 志丹县| 南通市| 贺州市| 陵川县| 来凤县| 平安县| 泌阳县| 宁南县| 合阳县| 翁牛特旗| 八宿县| 垣曲县| 汤阴县| 屯门区| 兴安县| 京山县| 康定县| 聂拉木县| 大关县| 景洪市| 黄骅市| 罗甸县| 株洲市| 兖州市| 东莞市| 佳木斯市| 佛教| 中超| 内黄县| 白河县| 朔州市| 东明县|