詳解微信小程序 template添加綁定事件
更新時間:2017年06月23日 09:05:05 作者:xiaochun365
這篇文章主要介紹了詳解微信小程序 template添加綁定事件的相關資料,需要的朋友可以參考下
詳解微信小程序 template添加綁定事件
對于模板的使用,我是想將模板的事件單獨出來,其他引用模板的頁面中不再摻雜模板事件,比較方便管理,如果還有其他好的解決辦法, 請賜教。
template.wxml
<view bindtap="clickView" class="tempClass">temp模板</view>
template.js
var temp = {
clickView: function () {
console.log("剛剛您點擊了temp")
}
}
export default temp
template.wxss
.tempClass {
background-color: red;
}
index.wxml 引用template模板
<!--index.wxml--> <view>body</view> <include src="../temp/temp.wxml" />
index.js
const App = getApp()
import tempObj from '../temp/temp'
//index.js
//獲取應用實例
var indexObj = {
onShow() {
console.log("onShow")
}
}
indexObj["clickView"] = tempObj.clickView
Page(indexObj)
index.wxss
/**index.wxss**/ @import "../temp/temp.wxss";
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關文章
微信小程序 中wx.chooseAddress(OBJECT)實例詳解
這篇文章主要介紹了微信小程序 中wx.chooseAddress(OBJECT)實例詳解的相關資料,需要的朋友可以參考下2017-03-03

