zoukankan      html  css  js  c++  java
  • 小程序使用模板template

    小程序使用模板template

    1.介绍模板就是代码的高度复用,将在很多页面使用了相同的部分可以使用模板封装

    <!-- 在页面组件中使用 -->
    
    <!-- 此时定义了一个模板 -->
    <template name="staffName">
      <view>
        FirstName: {{firstName}}, LastName: {{lastName}}
      </view>
    </template>
    
    
    <!-- 通过is属性指定使用哪个模板,...staffA是传入的数据 -->
    <template is="staffName" data="{{...staffA}}"></template>
    
    
    <!-- 通过外链使用,根目录下新建templates目录,再新建的demo目录,目录下有index.wxml和index.wxss -->
    
    <!-- 在页面组件中引入使用 -->
    
    <import src="../../templates/demo/index.wxml" />
    
    <template is="last" data="{{msg}}"></template>
  • 相关阅读:
    简单工厂模式
    原型模式
    特性Attribute
    MVC_Route层层深入
    异步Async
    sql-connectionStrings
    观察者模式(利用委托)
    SqlServer_存储过程
    c语言----程序记录
    c语言基础笔记
  • 原文地址:https://www.cnblogs.com/zxuedong/p/12910164.html
Copyright © 2011-2022 走看看