What is the difference between the js customization module export and the mixin of vue?

my idea is that vue"s mixin can also be written as js custom module export, and then import comes in
is code reuse
but I changed mixn to js module, and there"s a big problem

.
vue.esm.js?efeb:1741 TypeError: Cannot read property "components" of undefined
    at checkComponents (vue.esm.js?efeb:1330)
    at mergeOptions (vue.esm.js?efeb:1451)
    at mergeOptions (vue.esm.js?efeb:1467)
    at Function.Vue.extend (vue.esm.js?efeb:4803)
    at createComponent (vue.esm.js?efeb:4203)
    at _createElement (vue.esm.js?efeb:4420)
    at createElement (vue.esm.js?efeb:4357)
    at vm._c (vue.esm.js?efeb:4489)
    at Proxy.render (eval at ./node_modules/vue-loader/lib/template-compiler/index.js?{"id":"data-v-0ffbc2a2","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/components/news/detail/comment/Item.vue (app.js:7208), <anonymous>:144:13)
    at VueComponent.Vue._render (vue.esm.js?efeb:4544)

procedure is whether the result returned by me using the js module method is displayed as a component or not v-if

//lib.js
let checkIsLogin= async function(){     
    const res = await  api.auth.current({});
    return res.isLoggedIn;     
};
//componnts.vue
lib.checkIsLogin().then(function(res){               
    this.replying =  res;
})

<child v-if="replying "></child>
Apr.03,2021

mixin is also js, but mixin writes a mixture of vue components. Attributes in vue components, such as methods, computed, data, etc., can all be reused using mixin, which is essentially no different from js. For example, if you have a common method, you can also write a js file, export a method, and then reference it in a vue component, but this is more tortuous. It is not as convenient as writing mixin directly, and it is written as method, in mixin. In this method, you can also directly access variables in the component instance, reference components, and so on.

Menu