vue中.install方法的使用如同vue.use(),具体如下:
1、新建一个test.vue文件
<template>
<div>
一个测试组件
</div>
</template>
<script>
export default {
}
</script>
2、在同一目录下建立index.js文件,在这个文件中使用install方法来全局注册该组件
import test from './test.vue';
test.install = function (Vue) {
Vue.component(test.name, test );
};
export default test ;
3、使用
<template>
<div>
<test ></test >
</div>
</template>
<script>
import test from '@/components/test ';
export default {
components: {
test
},
}
</script>
原文链接:https://blog.csdn.net/swx999/article/details/112169349