vue 混合器mixins

引入混合器的页面都会先在本页面mounted之前执行混合器的代码

<script>
import {logMixins} from '@/utils/masterLogMixins.js';
export default {
    name: "DailyWork",
    mixins: [logMixins],
    data: function() {
        return {
        };
    },
    props: {
    },
    computed: {
    },
    components: {
    },
    watch: {
    },
    methods: {
    },
    created() {
    },
    mounted: async function() {
    }
};
</script>

masterLogMixins.js

import {voxTianShuLog} from "@/utils/index";
export const logMixins = {
    data() {
        return {
            masterLogS0: {}
        };
    },
    computed: {
    },
    components: {
    },
    watch: {
    },
    methods: {
    },
    mounted() {
        let vm = this;
        vm.masterLogS0 = {
            area_name: "1111",
            school_name: "1111",
            user_role: 0, //0 教研员 1校长 2教务老师 3局长 4区域管理者
            page_name: "1111",
        };

        voxTianShuLog({
            module: "m_NdRCbETke0",
            op: "o_e0a2YE3VPQ",
            s0: JSON.stringify(Object.assign({}, vm.masterLogS0, {screen_hight: window.screen.height, screen_width: window.screen.width}))
        });
    }
};

上一篇:Vue.js知识点汇集


下一篇:vue面试题(五)