我在东北烤地瓜

I am kaodigua I am chirourou I am qiaodaima

导航

provide inject

provide inject

<!-- father -->
import Store from './store.js'
 data() {
        const store = new Store(this)
        return {
            store,
            holdLoading: false,
            addLoading: false
        }
    },
    provide() {
        return {
            store: this.store
        }
    },
    mounted() {
        this.store.init()
    },

    <!-- body: -->

    inject: ['store'],

    store.js

import Vue from 'vue'

import store from '@/store.js'
const _vm = Vue.prototype
const Store = function () {
    // 根实例
    this.commodityProp = "商品名"
    // 页面响应
    this.pageLoading = false
    this.pageErr = null
}
Store.prototype.operatePriceList = function () {}

posted on 2021-11-18 15:32  我在东北烤地瓜  阅读(11)  评论(0编辑  收藏  举报