重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
這篇文章將為大家詳細講解有關微信小程序中template模板引用的示例分析,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
我們提供的服務有:成都網站設計、網站制作、微信公眾號開發、網站優化、網站認證、武定ssl等。為1000+企事業單位解決了網站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的武定網站制作公司
微信小程序視圖template模板引用的實例詳解
WXML 提供兩種文件引用方式import和include。
include可以將目標文件除了的整個代碼引入,相當于是拷貝到include位置
temlate.wxml
{{item.date}}{{idx}} {{item.title}} {{item.content}} 66 88
redirect.wxml引用
template.js
var content_for = [ { date: "2020年 10月 9日 ", title: "那年夏天", header_url: "/images/3.png", image_url: "/images/6.jpg", content: "天不言自高,地不言自厚,奇跡,是不會在容易的道路上綻放的。人生沒有如果,只有后果和結果,過去的不再回來,回來的不再完美。", }, { date: "2022年 10月 9日 ", title: "夏天", header_url: "/images/3.png", image_url: "/images/8.jpg", content: "人生沒有如果,只有后果和結果,過去的不再回來,回來的不再完美。", }, ] //輸出出口 module.exports={ templates: content_for }
redirect.js引用
var content_data=require('../../template/template.js') // pages/redirect/redirect.js Page({ /** * 頁面的初始數據 */ data: { }, /** * 生命周期函數--監聽頁面加載 */ onLoad: function (options) { this.setData({ key: content_data.templates }); } });
wxml
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; }
關于“微信小程序中template模板引用的示例分析”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。