ホームページ  >  記事  >  ウェブフロントエンド  >  WeChat ミニ プログラムにユーザー定義のテンプレートを実装する方法

WeChat ミニ プログラムにユーザー定義のテンプレートを実装する方法

亚连
亚连オリジナル
2018-06-23 17:51:151427ブラウズ

この記事では、主に WeChat ミニ プログラムのユーザー定義テンプレートの使用法を紹介し、WeChat ミニ プログラムのカスタム テンプレートの定義、データ呼び出し、レイアウト設定、その他の簡単な使用テクニックを、必要な友人が参照できるように詳細に分析します。この記事の例では、WeChat ミニ プログラムのユーザー定義テンプレートの使用方法について説明します。参考までに皆さんと共有してください。詳細は次のとおりです:

1. 新しい wxml を作成します (テストの便宜上、wxml ファイルはここのホーム ディレクトリに作成されます)

/home/home/botmenu.wxml :

<template name="bottommenu">
  <view class="bottomposition">
   <navigator class="item_info" url="../home/home">
     <image src="../img/sy.png"></image>
     <text>首页</text>
   </navigator>
   <navigator class="item_info" url="/pages/home/home">
     <image src="../img/xx.png"></image>
     <text>消息</text>
   </navigator>
   <navigator class="item_info" url="/pages/home/home">
     <image src="../img/lz.png"></image>
     <text>工具</text>
   </navigator>
   <navigator class="item_info" url="/pages/home/home">
     <image src="../img/wo.png"></image>
     <text>我</text>
   </navigator>
  </view>
</template>

2. 新しい wxss を作成します

/home/home/botmenu.wxss:

.bottomposition{
 width: 100%;
 height: 10%;
 position: fixed;
 overflow: hidden;
 left: 0;
 top: 90%;
z-index: 1100;
 display: flex;
 border-top: 1rpx solid #dadada;
}
.item_info {
 width: 25%;
 height: 100%;
 display: flex;
 align-items: center;
 flex-direction: column;
 justify-content: center;
}
.item_info image {
 width: 20px;
 height: 20px;
}
.item_info text {
 margin-top: 5px;
 font-size: 12px;
}
.infolist{
 margin:10px;
 padding: 0 10px;
 font-size: 12px;
}

3. ページの参照

<import src="../home/home.wxml"/>
<view class="info">
 <template is="bottommenu"></template>
</view>

4. Index.js のデータ データ:

@import "../home/home.wxss";

6.index.wxml

data: {
 tool_list:[{
  name:"在线JavaScript代码美化、格式化工具",
  url:"http://tools.jb51.net/code/js"
 },{
  name:"json代码在线格式化/美化/压缩/编辑/转换工具",
  url:"http://tools.jb51.net/code/jsoncodeformat"
 },{
  name:"中文繁体字简体字转换(繁简转换)工具",
  url:"http://tools.jb51.net/transcoding/convertzh"
 },{
  name:"正则表达式在线生成工具",
  url:"http://tools.jb51.net/regex/create_reg"
 },{
  name:"XML代码在线格式化美化工具",
  url:"http://tools.jb51.net/code/xmlcodeformat"
 },{
  name:"在线科学计算器",
  url:"http://tools.jb51.net/jisuanqi/jsqkexue"
 },{
  name:"BASE64编码解码工具",
  url:"http://tools.jb51.net/transcoding/base64"
 }]
 },

以上、皆様のお役に立てれば幸いです。

関連記事:

AngularJSのMVCに関する複雑な操作

CommonsChunkPluginを使用してパブリックモジュールを抽出する方法

ReactNativeを使用してToastを実装する方法

Angular CLIのインストールチュートリアル

非同期を実装するVuejs の nextTick() を通じてキューを更新します

以上がWeChat ミニ プログラムにユーザー定義のテンプレートを実装する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。