午夜91福利视频,午夜成人在线观看,午夜在线视频免费观看,午夜福利短视频,精品午夜成人免费视频APP

小程序模板網

微信小程序 template添加綁定事件

發布時間:2017-12-15 08:55 所屬欄目:小程序開發教程

對(dui)于模(mo)板(ban)的使用(yong),我是想將模(mo)板(ban)的事(shi)(shi)件單獨出來,其他(ta)引用(yong)模(mo)板(ban)的頁(ye)面中(zhong)不再摻雜(za)模(mo)板(ban)事(shi)(shi)件,比(bi)較方便管(guan)理,如(ru)果還有其他(ta)好的解 ...

 
 
 

對于模板(ban)的(de)使(shi)用,我是想將模板(ban)的(de)事(shi)件單獨出來(lai),其他(ta)引用模板(ban)的(de)頁面中不再摻(chan)雜模板(ban)事(shi)件,比較方便(bian)管理,如(ru)果還有其他(ta)好的(de)解決辦(ban)法, 請賜教。

template.wxml

<view bindtap="clickView" class="tempClass">temp模板view>
  • 1
  • 1

template.js

var temp = {
  clickView: function () {
    console.log("剛剛您點擊了(le)temp")
  }
}
export default temp
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

template.wxss

.tempClass {
  background-color: red;
}
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

————————————————————————  index.wxml 引用template模板


<view>bodyview>
<include src="../temp/temp.wxml" />
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

index.js

const App = getApp()
import tempObj from '../temp/temp'

//index.js
//獲(huo)取(qu)應(ying)用(yong)實例
var indexObj = {
  onShow() {
    console.log("onShow")
  }
}
indexObj["clickView"] = tempObj.clickView
Page(indexObj)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

index.wxss

/**index.wxss**/
@import "../temp/temp.wxss";


易(yi)優小(xiao)程序(xu)(企業版)+靈活(huo)api+前(qian)后代碼開源(yuan) 碼云倉庫:
本文地址://www.jinyoudianli.com/wxmini/doc/course/18167.html 復制鏈接 如需(xu)定制請聯系易優(you)客服(fu)咨詢:

工作日 8:30-12:00 14:30-18:00
周六及部分節(jie)假日提供值班服(fu)務

易(yi)小(xiao)優
轉人工 ×