美文网首页
wepy 模板

wepy 模板

作者: 喵整点薯条 | 来源:发表于2019-01-09 21:57 被阅读13次

页面模板:

<template>
    <view class="basic">
        basic
    </view>
</template>

<script>
import wepy from 'wepy';

export default class Basic extends wepy.page {
    config = {
        navigationBarTitleText: ''
    };
    components = {
    };
    data = {
    };
    methods = {
    };
    onLoad () {

    }
    onShow () {

    }
}
</script>
<style lang="less">
.basic {

}
</style>

组件模板:

<template>
    <view>
        basic
    </view>
</template>

<script>
import wepy from 'wepy';

export default class Basic extends wepy.component {
    props = {
        // placeholder: {
        //     type: String,
        //     default: '请输入要搜索商品的名称'
        // },  // 搜索框的提示词
    };
    data = {   
    };
    methods = {
    };
}
</script>

mixin 模板:

// mixins/test.js
import wepy from 'wepy';

export default class TestMixin extends wepy.mixin {
    data = {};
    methods = {};
    onShow () {}
}

// 引用
import TestMixin from './mixins/test';

mixins = [TestMixin];

常用for 循环,组件循环要用repeat

<block wx:for="{{ star }}" wx:for-item="i" wx:for-index="tab_i" wx:key="index">
</block>

<!-- 注意,使用for属性,而不是使用wx:for属性 -->
 <repeat for="{{list}}" key="index" index="index" item="item">
     <!-- 插入<script>脚本部分所声明的child组件,同时传入item -->
     <child :item="item"></child>
 </repeat>

相关文章

网友评论

      本文标题:wepy 模板

      本文链接:https://www.haomeiwen.com/subject/tflymftx.html