• 「小程序JAVA实战」小程序模板在外部页面引用(20)


    转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-20/

    不知道老铁还有印象吗?当时讲模板的时候,是在当前的页面进行模板的应用,如何外部的方式引用模板呢?源码:https://github.com/limingios/wxProgram.git 中的No.8

    小程序的引入外部的模板

    模板创建后,如何在别的页面别的地方引用。

    1. 模板在某个wxml中应以完毕后可以被其他页面引用
    2. 关键字 import
    3. A 引用B, B引用C,A不能引用C
    4. 官方的阐述
      >https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/import.html

    1. 演示调用外部的模板
      >import可以在该文件中使用目标文件定义的template。

    templateImport.wxml


    <import src="../templateIs/templateIs.wxml"/> <view class="container"> <template is="mytemp" data="{{...person,msg,name:'limng',age:'永远18岁'}}" /> <template is="mytemp" data="{{...person,msg,name:'limng',age:'永远18岁'}}" /> <template is="mytemp" data="{{...person,msg,name:'limng',age:'永远18岁'}}" /> </view>

    templateImport.js

    //templateImport.js
    //获取应用实例
    const app = getApp()
    
    Page({
      data: {
        person: {
          address: "公众号:编程坑太多",
          remark: "个人主页:www.idig8.com"
        },
        msg: "感谢关注,收藏!"
      }
    })
    

    PS:这个就是使用import 针对外部文件的导入。

  • 相关阅读:
    【题解】 P1373 小a和uim之大逃离
    题解 CF576C 【Points on Plane】
    题解 P4799 【[CEOI2015 Day2]世界冰球锦标赛】
    【题解】[JSOI2008]最大数
    题解 P3389 【【模板】高斯消元法】
    【模板】矩阵加速
    【模板】树状数组上的差分数组
    tarjan求强连通分量(模板)
    我好菜系列——map查找
    trie树的应用;
  • 原文地址:https://www.cnblogs.com/sharpest/p/10284620.html
Copyright © 2020-2023  润新知