backBox.vue 1.43 KB
<template>
    <div class="back-box" v-if="backs">
		<div class="box">
			<div class="buttons-box">
				<img src="static/img/icon_back.png" class="back" @click="back" />
				<div class="func-box" v-if="backs && backs.funcs && backs.funcs.funcArray">
					<div class="func" v-if="backs.switch == index" v-for="(item, index) in backs.funcs.funcArray" :key="index" @click="func(backs)">
						{{item.text}}
					</div>
				</div>
			</div>
			<div class="title" v-if="backs.title">{{backs.title}}</div>
		</div>
    </div>
</template>

<script>
    export default {
        data: function () {
            return {
                switch: false
            }
        },
        props: ["backs"],
		methods: {
			
			/**
			 * 返回
			 */
			back() {
				if (typeof this.backs.funcs === "object" && typeof this.backs.funcs.back === "function") {
					this.backs.funcs.back();
				}
			},

			/**
			 * 功能按钮
			 * @param {object} backs [props对象]
			 */
			func(backs) {
				if (typeof this.backs.funcs === "object" && typeof this.backs.funcs.funcArray === "object" && typeof this.backs.funcs.funcArray[this.backs.switch] === "object" && typeof this.backs.funcs.funcArray[this.backs.switch].func === "function") {
					this.backs.funcs.funcArray[this.backs.switch].func(backs);
				}
			}
		}
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less">
    @import './backBox';
</style>