自定义弹出层, 内容可自定义修改, 简单易操作

Popup 弹出层
组件名:open-alert,代码块: openAlert。
使用方式

在 main.js 中引用组件

import openAlert from '@/components/open-alert/open-alert';
Vue.component('openAlert', openAlert);

 

在 template 中使用组件

<view class="open-view" @tap="open(0, 'center')">淡入</view>
<openAlert ref="openAlert" :AlertClass="AlertClass" :AlertPosition="AlertPosition">
    <view>自定义内容</view>
</openAlert>

export default {
    data() {
        return {
            AlertClass: 0,
            AlertPosition: '',
        };
    },
    methods: {
        open(Class, Position) {
            this.$nextTick(function() {
                this.AlertClass = Class;
                this.AlertPosition = Position;
                this.$nextTick(function() {
                    this.$refs.openAlert.Show();
                });
            });
        }
    }
};

评论

全部评论