wepy 页面index.wpy
<style type="less">
/** less **/
</style>
<template type="wxml">
<view>
</view>
<component id="counter1" path="counter"></component>
</template>
<script>
import wepy form 'wepy';
import Counter from '../components/counter';
export default class Index extends wepy.page {
config = {};
components = {counter1: Counter};
data = {};
methods = {};
events = {};
onLoad() {};
// Other properties
}
</script>页面入口继承自wepy.page,主要属性说明如下:
| 属性 | 说明 |
|---|---|
| config | 页面config,相当于原来的index.json,同app.wpy中的config |
| components | 页面引入的组件列表 |
| data | 页面需要渲染的数据 |
| methods | wmxl的事件捕捉,如bindtap,bindchange |
| events | 组件之间通过broadcast,emit传递的事件 |
| 其它 | 如onLoad,onReady等小程序事件以及其它自定义方法与属性 |